Results 1 to 6 of 6

Thread: Qt application output says crashed

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #3
    Join Date
    Oct 2009
    Posts
    483
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Thanked 97 Times in 94 Posts

    Default Re: Qt application output says crashed

    Does the output show "-x-x-x- Count Reached 10 -x-x-x-" if you wait long enough?

    There is nothing wrong with your application, except that:
    • there is a race condition between slots: worker->stopThread() is connected to both timer.stop() and worker->deleteLater(); worker could be deleted first, thus preventing timer.stop() from being run. Since the order in which the slots are run is unspecified in general, this may or may not happen in practice.
    • the application never terminates. Nothing causes the event loop to exit.

    I cannot see why stopping the timer would be necessary. However, you should probably exit the event loop cleanly. Here is a proposal that exits the program after the worker has finished its work:
    Qt Code:
    1. int main(int argc, char *argv[])
    2. {
    3. QCoreApplication a(argc, argv);
    4. QTimer timer;
    5. Worker worker; // No need to allocate this on the heap; the stack is fine, and the object will be automatically destroyed at the end of the function (just like a and timer)
    6. QCoreApplication::connect(&timer, SIGNAL(timeout()), &worker, SLOT(process()));
    7. QCoreApplication::connect(&worker, SIGNAL(stopThread()), &a, SLOT(quit()));
    8. timer.start(1000);
    9. return a.exec();
    10. }
    To copy to clipboard, switch view to plain text mode 

  2. The following user says thank you to yeye_olive for this useful post:

    rawfool (3rd August 2015)

Similar Threads

  1. Replies: 1
    Last Post: 17th November 2015, 14:11
  2. prints nothing in application output
    By ramin.lich in forum Newbie
    Replies: 2
    Last Post: 1st October 2014, 09:46
  3. Application output pane
    By stef13013 in forum Newbie
    Replies: 2
    Last Post: 30th June 2013, 18:31
  4. Replies: 3
    Last Post: 27th August 2011, 21:44
  5. Error message: The Application crashed
    By josecarlosmissias in forum Newbie
    Replies: 13
    Last Post: 10th December 2009, 16:38

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.