Results 1 to 9 of 9

Thread: QThread crashes on exit

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QThread crashes on exit

    Quote Originally Posted by mhoover View Post
    In this case the threads are declared as member variables on the stack, so the threads can't be uninitialized pointers.
    Sure they can.

    The other thing is I wonder how a private Qt-class variable is not initialized ...
    Probably because it was deleted or has not been initialized yet. Or... you have stack corruption.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


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

    mhoover (25th August 2009)

  3. #2
    Join Date
    Jan 2006
    Location
    Maui, Hawaii
    Posts
    120
    Thanks
    65
    Thanked 4 Times in 4 Posts
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QThread crashes on exit

    Thanks again, everyone for your help.

    This solved the problem:

    Qt Code:
    1. UDPThread::~UDPThread()
    2. {
    3. exit();
    4. while( this->isRunning() == true ) {
    5.  
    6. }
    7.  
    8. }
    To copy to clipboard, switch view to plain text mode 

    My assumption was exit() didn't return until the thread was finished running, but it keeps going.

    It looks like exit() stops the event loop and then stops the run() a bit later.
    Last edited by mhoover; 25th August 2009 at 22:34.

  4. #3
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QThread crashes on exit

    try to use "native" methods of QThread
    Qt Code:
    1. UDPThread::~UDPThread()
    2. {
    3. if (isRunning()) {
    4. quit();
    5. wait();
    6. }
    7. }
    To copy to clipboard, switch view to plain text mode 
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

  5. #4
    Join Date
    Jan 2006
    Location
    Maui, Hawaii
    Posts
    120
    Thanks
    65
    Thanked 4 Times in 4 Posts
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QThread crashes on exit

    Oh, right.

    I was trying to use the intellisense thing to quickly see what methods were available.

    I will change it.

Similar Threads

  1. QThread and QTcpSocket
    By ^NyAw^ in forum Qt Programming
    Replies: 3
    Last Post: 12th May 2008, 13:06
  2. QThread exec proplem to stop...
    By patrik08 in forum Qt Programming
    Replies: 29
    Last Post: 21st May 2007, 07:51
  3. KDE/QWT doubt on debian sarge
    By hildebrand in forum KDE Forum
    Replies: 13
    Last Post: 25th April 2007, 06:13
  4. QThread stack overflow when exiting
    By jakamph in forum Qt Programming
    Replies: 4
    Last Post: 11th May 2006, 17:56
  5. Is it possible to create a QThread without inheriting ?
    By probine in forum Qt Programming
    Replies: 6
    Last Post: 23rd March 2006, 22:51

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.