Results 1 to 20 of 33

Thread: QObject::killTimers() warning after timer stopped from its own thread

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #5
    Join Date
    Oct 2012
    Location
    The land of pain (NY)
    Posts
    99
    Qt products
    Qt4 Qt/Embedded
    Platforms
    MacOS X Windows Android
    Thanks
    7
    Thanked 3 Times in 2 Posts

    Default Re: QObject::killTimers() warning after timer stopped from its own thread

    Quote Originally Posted by amleto View Post
    ok, next try. Does this give same thread timer warning?

    Qt Code:
    1. FlashWizard::FlashWizard(...)
    2. {
    3. ...
    4. worker = new Worker;
    5.  
    6. qDebug() << worker->thread();
    7.  
    8. workerThread = new QThread;
    9. worker->moveToThread(workerThread);
    10.  
    11. qDebug() << worker->thread();
    12. qDebug() << worker->m_workerTimer->thread();
    13.  
    14. //connect(workerThread, SIGNAL(started()), worker, SLOT(start()));
    15. connect(workerThread, SIGNAL(finished()), worker, SLOT(stop()));
    16. connect(worker, SIGNAL(finished()), workerThread, SLOT(quit()));
    17. connect(worker, SIGNAL(finished()), ui->programPage, SLOT(setDone()));
    18. connect(worker, SIGNAL(updateProgress(int)), this, SLOT(updateWritingProgressBar(int)));
    19.  
    20. workerThread->start();
    21. QMetaObject::invokeMethod(worker, "start");
    22. QMetaObject::invokeMethod(worker, "stop");
    23. }
    To copy to clipboard, switch view to plain text mode 
    Yes the same message. For what it's worth, I want to note that I get the warning both calling start in the constructor or calling start (where it originally resides) in the slot that's called for the page that displays the progress bar. I just wanted to see if there was a difference - there isn't.

    I took out calling new on the timer in the constructor for the worker. So I now use a reference for the timer in the connect call in the rather than a pointer in start method in the worker:

    Qt Code:
    1. void Worker::start()
    2. {
    3. connect(&m_workerTimer, SIGNAL(timeout()), this, SLOT(doWork()));
    4. m_workerTimer.start(100);
    5. doWork();
    6. }
    To copy to clipboard, switch view to plain text mode 

    Unexpectedly, I don't see the warning now until the worker completes - not when I click the cancel button, which was the previous case.

    Qt Code:
    1. void FlashWizard::reject()
    2. {
    3. if (workerThread->isRunning())
    4. {
    5. worker->stop();
    6. }
    7. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by astodolski; 15th December 2012 at 14:35. Reason: updated contents

Similar Threads

  1. Replies: 1
    Last Post: 29th July 2010, 05:41
  2. QObject::killTimer Warning Messages
    By mclark in forum Qt Programming
    Replies: 7
    Last Post: 11th September 2008, 20:10
  3. how to enable a timer in a non-gui thread?
    By zeopha in forum Qt Programming
    Replies: 3
    Last Post: 5th August 2008, 09:29
  4. Replies: 2
    Last Post: 24th March 2008, 16:59
  5. QObject::moveToThread warning
    By mnemonic_fx in forum Qt Programming
    Replies: 3
    Last Post: 10th August 2007, 22:11

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.