Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
Developer
Posts: 74
Registered: ‎01-08-2013
My Device: Playbook
My Carrier: NA
Accepted Solution

QTimer connect woes on Z10

[ Edited ]


Hello,

I have an app that uses QTimer class to schedule stuff. It allows setting the interval in seconds / minutes / hours.

This works great in simulator but fails in some(many?) Z10.

Today, an app update got released that allows logging.

2 people tested it and gave logs. 1 Blackberry Support guy confirmed to me that setting Timer interval in
seconds does not work , but setting say 1 minute works.
A Customer however confirmed that neither works for him.

From the logs provided by both , it looks like  QTimer connection with callback is failing sometimes

This is the code i use

    if( interval_timer == 0 ){                                            // Allocate and setup Timer once
        interval_timer = new QTimer();

        bool connected = false;
        Q_ASSERT( connected = QObject::connect(interval_timer, SIGNAL(timeout()), this, SLOT( changeWallpaper()) )  ) ;

        LOG2( "connected:" , connected ) ;
    }

The Timer eventually gets setup correctly ( interval and isActive ) but because callback registration failed nothing is called

The callback slot is defined like this :

    Q_SLOT         void     changeWallpaper(bool is_next_clicked = true);    

Now i think the problem is the use of default parameters but this works everytime in simulator.

Would someone be willing to test my app in a Z10 ? I dont have a device yet.

I can create two bars before and after fix. (I am assuming we can push a release mode bar file in device) .

Any help would be appreciated as app approvals can take long time.

thanks





Developer
Posts: 1,746
Registered: ‎04-08-2010
My Device: Passport Silver, PRIV
My Carrier: Telekom.de, O2, Vodafone

Re: QTimer connect woes on Z10

don't know if this helps you, but I'm using QTimer from QML and it works

tested with intervals of 1000 ms and runs for 0::30 to 5:00 minutes or so

QTimer {
                id: timer
                interval: 1000 // teaPage.teatime
                onTimeout: {
                    teaPage.usedtime += 1000
                    if(teaPage.usedtime >= teaPage.teatime){
                        timer.stop()
                        brewedTime.text = ""
                        teaPage.countdown = 0
                        teaPage.usedtime = 0
                        teaPage.teaReady()
                    } else {
                        teaPage.countdown = (teaPage.teatime - teaPage.usedtime)
                        var d = new Date(teaPage.countdown);
                        brewedTime.text = Qt.formatDateTime(d, "mm:ss")
                    }
                }
            }

 if you download my TeaTimer (haha) from BlackBerry World you can see that it works, the timer was decreased and it was also running in the background while minimized

-------------------------------------------------------------------------------
ekke (independent software architect, rosenheim, germany)

BlackBerry Elite Developer
BlackBerry Platinum Enterprise Partner
International Development native Mobile Business Apps
BlackBerry 10 | Qt Mobile (Android, iOS)
Workshops / Trainings / Bootcamps

blog: http://ekkes-corner.org
mobile-development: http://appbus.org Twitter: @ekkescorner
Developer
Posts: 74
Registered: ‎01-08-2013
My Device: Playbook
My Carrier: NA

Re: QTimer connect woes on Z10

[ Edited ]

 

Yes i believe the problem is caused by the default parameters that i used in SLOT .

I even found a comment that QT 5 removes support for this.

 

I think removing it should make it work. Otherwise i can ofc use the qml version.

Would you be willing to test my bar file ?

 

i have the fix an i am testing it in simulator

 

EDIT : in simulator this works even now so i cannot confirm if it works in Z10.

That is why i need to confirm it in a Z10.

Developer
Posts: 285
Registered: ‎08-06-2010
My Device: Z10

Re: QTimer connect woes on Z10

I would suggest implementing timer based logic entirely in C++ and then using signals to communicate with your QML. I've found this way to be much simpler as dealing with QTimer in QML is very nasty.



Follow me on twitter @RileyGB - https://twitter.com/RileyGB
View my BB10 OpenSource projects - https://github.com/RileyGB/BlackBerry10-Samples
Developer
Posts: 74
Registered: ‎01-08-2013
My Device: Playbook
My Carrier: NA

Re: QTimer connect woes on Z10

 

Right now everything is in C++ for QTimer . I only need to remove the default parameter from SLOT and it should work.

 

Strange that it worked in simulator but not in Z10. That i dont understand

Developer
Posts: 1,746
Registered: ‎04-08-2010
My Device: Passport Silver, PRIV
My Carrier: Telekom.de, O2, Vodafone

Re: QTimer connect woes on Z10


SpacemanSpiff wrote:

 

...

I think removing it should make it work. Otherwise i can ofc use the qml version.

Would you be willing to test my bar file ?

 

...

sorry... no time today Smiley Sad

just finishing my materials to submit to bblive achievement awards

and tomorrow in frankfurt at blackberry experience forum (BEF)

-------------------------------------------------------------------------------
ekke (independent software architect, rosenheim, germany)

BlackBerry Elite Developer
BlackBerry Platinum Enterprise Partner
International Development native Mobile Business Apps
BlackBerry 10 | Qt Mobile (Android, iOS)
Workshops / Trainings / Bootcamps

blog: http://ekkes-corner.org
mobile-development: http://appbus.org Twitter: @ekkescorner
Developer
Posts: 74
Registered: ‎01-08-2013
My Device: Playbook
My Carrier: NA

Re: QTimer connect woes on Z10

Sure thanks

 

Ill wait for anyone to agree to test it. Good luck for the awards , I see you even teach cascades Smiley Happy

Developer
Posts: 1,524
Registered: ‎12-18-2012
My Device: Z30, Z10 LE, DevAlpha C, PlayBook

Re: QTimer connect woes on Z10

[ Edited ]

Hi,

 

Q_ASSERT( connected = QObject::connect(interval_timer, SIGNAL(timeout()), this, SLOT( changeWallpaper()) )  ) ;

 

This line will be omitted when compiling in release mode and the signal will not be connected. Try replacing it with:

 

connected = QObject::connect(interval_timer, SIGNAL(timeout()), this, SLOT( changeWallpaper()) ) ;

Q_ASSERT( connected ) ;

 


Andrey Fidrya, @zmeyc on twitter
Developer
Posts: 74
Registered: ‎01-08-2013
My Device: Playbook
My Carrier: NA

Re: QTimer connect woes on Z10

[ Edited ]

holy mother of god , i didnt know that .

thank you very much.

 

Now it all makes sense.

 

 

BTW , is there a way to test release build in x86 simulator ? can we have a x86 release mode bar file

 

Developer
Posts: 196
Registered: ‎03-04-2013
My Device: BB Z10
My Carrier: Rogers

Re: QTimer connect woes on Z10

[ Edited ]

So, yeah expanding on what Zmey already mentioned... This is from the QtGlobal description for the Q_ASSERT() macro...

 

Q_ASSERT() is useful for testing pre- and post-conditions during development. It does nothing if QT_NO_DEBUG was defined during compilation.