×

Discussion Board

Results 1 to 14 of 14
  1. #1
    Registered User
    Join Date
    Jul 2008
    Posts
    103

    Strange QTimer problem (3 minute stops)

    I have a timer in a class:
    Code:
        timeCounter = 0;
        connect(&timer, SIGNAL(timeout()), this, SLOT(updateData()));
        timer.start(1000);
    The updateData() is something like:

    Code:
    void MyClass::updateData()
    {
        timeCounter++;
        debugText.append("\nupdateData start " + QDateTime::currentDateTime().toString() + " " +
                         QString::number(timeCounter));
        ...
        // Get some data from GPS
        ...
    
        if( (timeCounter % FIXED_DELAY) == 0) ) {
            ...
            // Store some data in a QList
            ...
            // Http post some data to some server
            ...
        }
    
        emit updateInterfaceData();
    
        if(timeCounter % DEBUG_DELAY == 0)  {
            QFile debugFile(DEBUG_LOCATION);
            if(debugFile.open(QIODevice::Append | QIODevice::Text)) {
                QTextStream debugStream(&debugFile);
                debugStream<<debugText;
                debugFile.close();
                debugText = "";
            }
        }
        debugText.append("\nupdateData end " + QDateTime::currentDateTime().toString() + " " +
                         QString::number(timeCounter));
    }
    I know that probably calling a method which uses Http post might be wrong (or are the Http methods already threaded and they don't add much delay to the updateData method?), but when this code runs in some phones (most of them S60 3rd edition), the timer does not timeout every second and there are sometimes 3 minutes gaps between timeouts (which is really strange that most of them are EXACTLY 3 minutes).

    Here's a sample of the debug text:
    Code:
    updateData start Fri Nov 4 09:01:32 2011 1
    updateData end Fri Nov 4 09:01:32 2011 1
    updateData start Fri Nov 4 09:01:33 2011 2
    updateData end Fri Nov 4 09:01:33 2011 2
    updateData start Fri Nov 4 09:01:34 2011 3
    updateData end Fri Nov 4 09:01:34 2011 3
    updateData start Fri Nov 4 09:01:35 2011 4
    updateData end Fri Nov 4 09:01:35 2011 4
    updateData start Fri Nov 4 09:01:36 2011 5
    updateData end Fri Nov 4 09:01:36 2011 5
    updateData start Fri Nov 4 09:01:37 2011 6
    updateData end Fri Nov 4 09:01:37 2011 6
    updateData start Fri Nov 4 09:01:38 2011 7
    updateData end Fri Nov 4 09:01:38 2011 7
    updateData start Fri Nov 4 09:01:39 2011 8
    updateData end Fri Nov 4 09:01:39 2011 8
    updateData start Fri Nov 4 09:01:40 2011 9
    updateData end Fri Nov 4 09:01:40 2011 9
    updateData start Fri Nov 4 09:01:41 2011 10
    updateData end Fri Nov 4 09:01:41 2011 10
    updateData start Fri Nov 4 09:04:06 2011 11
    updateData end Fri Nov 4 09:04:06 2011 11
    updateData start Fri Nov 4 09:04:07 2011 12
    updateData end Fri Nov 4 09:04:07 2011 12
    updateData start Fri Nov 4 09:04:08 2011 13
    updateData end Fri Nov 4 09:04:08 2011 13
    updateData start Fri Nov 4 09:04:09 2011 14
    updateData end Fri Nov 4 09:04:09 2011 14
    updateData start Fri Nov 4 09:07:09 2011 15
    updateData end Fri Nov 4 09:07:09 2011 15
    updateData start Fri Nov 4 09:07:10 2011 16
    updateData end Fri Nov 4 09:07:10 2011 16
    updateData start Fri Nov 4 09:07:11 2011 17
    updateData end Fri Nov 4 09:07:11 2011 17
    updateData start Fri Nov 4 09:07:12 2011 18
    updateData end Fri Nov 4 09:07:13 2011 18
    updateData start Fri Nov 4 09:07:14 2011 19
    updateData end Fri Nov 4 09:07:14 2011 19
    updateData start Fri Nov 4 09:10:14 2011 20
    updateData end Fri Nov 4 09:10:14 2011 20
    updateData start Fri Nov 4 09:10:15 2011 21
    updateData end Fri Nov 4 09:10:15 2011 21
    updateData start Fri Nov 4 09:10:16 2011 22
    updateData end Fri Nov 4 09:10:16 2011 22
    updateData start Fri Nov 4 09:10:17 2011 23
    updateData end Fri Nov 4 09:10:17 2011 23
    updateData start Fri Nov 4 09:13:17 2011 24
    updateData end Fri Nov 4 09:13:17 2011 24
    updateData start Fri Nov 4 09:13:18 2011 25
    updateData end Fri Nov 4 09:13:19 2011 25
    updateData start Fri Nov 4 09:13:20 2011 26
    updateData end Fri Nov 4 09:13:20 2011 26
    updateData start Fri Nov 4 09:13:21 2011 27
    updateData end Fri Nov 4 09:13:21 2011 27
    updateData start Fri Nov 4 09:16:21 2011 28
    updateData end Fri Nov 4 09:16:21 2011 28
    updateData start Fri Nov 4 09:16:22 2011 29
    updateData end Fri Nov 4 09:16:22 2011 29
    You can see the timer timeouts correctly until 09:01:41, then it has a pause of 2:37, then it has a some gaps which are all the time 3 minutes.

    Any idea what could be the cause of this? Does the updateData method take too much time to run, is there a thread limit in Symbian and that could also interfere with the timer or is there other logical explanation?

  2. #2
    Registered User
    Join Date
    Oct 2011
    Posts
    11

    Re: Strange QTimer problem (3 minute stops)

    It would maybe be a bit easier to locate the cause if you'd put some more debug prints in there so that you'd know exactly where the pause happens, for example check how long it takes to get the GPS data and how long it takes to do the Http post.

  3. #3
    Registered User
    Join Date
    Jul 2008
    Posts
    103

    Re: Strange QTimer problem (3 minute stops)

    As you can see for the debug text, the execution time for updateData() is under 1 second every time, but sometimes the timer does not emit timeout() signal.

    Does anyone know what could be a general cause of not emitting timeout() signal for a QTimer? Of course this class is part of a bigger application with several screens and other timers and which uses several resources, so what might prevent the timer to timeout?

  4. #4
    Super Contributor
    Join Date
    Oct 2008
    Location
    INDIA
    Posts
    2,326

    Re: Strange QTimer problem (3 minute stops)

    There are many QTimer related articles are given in the article section, try out and compare sort out your problem.

  5. #5
    Registered User
    Join Date
    Oct 2011
    Posts
    11

    Re: Strange QTimer problem (3 minute stops)

    Quote Originally Posted by catharsis View Post
    As you can see for the debug text, the execution time for updateData() is under 1 second every time, but sometimes the timer does not emit timeout() signal.

    Does anyone know what could be a general cause of not emitting timeout() signal for a QTimer? Of course this class is part of a bigger application with several screens and other timers and which uses several resources, so what might prevent the timer to timeout?
    Oh yeah, I didn't notice that :P.

    It seems like the time interval that is given to QTimer doesn't mean that the QTimer will be fired for say after 1 second, it means that the signal is not fired before atleast 1 second has passed, so there's definitely some events in your program that are blocking the timer from firing. Does this seem like a possible explanation?

  6. #6
    Registered User
    Join Date
    Jul 2008
    Posts
    103

    Re: Strange QTimer problem (3 minute stops)

    Yes, it seems like a possible expanation, but:
    1. What could block the timer from firing? (is there some timer number limit on Symbian or is there some limit of how many signal and slots are connected?)
    2. Why is the delay most of the times exactly 3 minutes? Is this a constant timeout to something which blocks the timer?

  7. #7
    Nokia Developer Champion
    Join Date
    Sep 2007
    Location
    Bhavnagar
    Posts
    928

    Re: Strange QTimer problem (3 minute stops)

    You had tried this code S60 3rd edition device or any other device also? what happen when you run this code in Qt SDK?
    Jajal Mehul

  8. #8
    Registered User
    Join Date
    Jul 2008
    Posts
    103

    Re: Strange QTimer problem (3 minute stops)

    The code was tested in 3rd edition, 5th edition and Symbian^3 phones. Mostly, it happened in 3rd edition models (C5 and 6210 Navigator), but it did not occur all the time (I would say in less than half of the cases). I cannot reproduce the exact conditions in which this occurs, but in repeated testing it does show up eventually.

    So my repeated question is: what could block a QTimer for emitting timeout signal ?

  9. #9
    Nokia Developer Champion
    Join Date
    Sep 2007
    Location
    Bhavnagar
    Posts
    928

    Re: Strange QTimer problem (3 minute stops)

    What about the testing in the 5th edition and S^3 devices? Does the delay generated on that device or not?
    Jajal Mehul

  10. #10
    Registered User
    Join Date
    Jul 2008
    Posts
    103

    Re: Strange QTimer problem (3 minute stops)

    Quote Originally Posted by catharsis View Post
    Mostly, it happened in 3rd edition models (C5 and 6210 Navigator)
    In 5th edition and S^3 I didn't see these kind of delays, although it may of happened once in 5th edition.

  11. #11
    Nokia Developer Champion
    Join Date
    Sep 2007
    Location
    Bhavnagar
    Posts
    928

    Re: Strange QTimer problem (3 minute stops)

    Check this bug report. It may be useful for you.

    https://bugreports.qt.nokia.com//browse/QTBUG-11642
    Jajal Mehul

  12. #12
    Registered User
    Join Date
    Oct 2011
    Posts
    11

    Re: Strange QTimer problem (3 minute stops)

    You said it didn't happen in the S^3 phones and that it might have happened once in the 5th ed. phone, so could it be platform specific? I don't know how well these older phones and their platforms are supported by Qt, but it seems like the project concentrates pretty much only on the S^3 platform...

  13. #13
    Super Contributor
    Join Date
    Oct 2008
    Location
    INDIA
    Posts
    2,326

    Re: Strange QTimer problem (3 minute stops)

    Quote Originally Posted by weeezes View Post
    You said it didn't happen in the S^3 phones and that it might have happened once in the 5th ed. phone, so could it be platform specific? I don't know how well these older phones and their platforms are supported by Qt, but it seems like the project concentrates pretty much only on the S^3 platform...
    Version of Qt differs in S^3 and S60 5th edition or older devices, that's why application deployment process is target dependent.

  14. #14
    Registered User
    Join Date
    Jul 2008
    Posts
    103

    Re: Strange QTimer problem (3 minute stops)

    Ok, so no clear reasons why the timer stops firing? Do you know any ways to check if the timer works or any methods to bypass this error?

Similar Threads

  1. Problem using Qtimer
    By fareenafatima in forum Qt
    Replies: 1
    Last Post: 2010-12-24, 01:32
  2. QTest unit testing QTimer problem
    By remy_david in forum Qt
    Replies: 1
    Last Post: 2010-12-10, 16:06
  3. QTimer Example
    By prathibha83 in forum Qt
    Replies: 4
    Last Post: 2010-05-02, 13:49
  4. Problem with Audio Stream - stops playing
    By michi2805 in forum Audio
    Replies: 2
    Last Post: 2009-04-15, 11:19

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×