Results 1 to 20 of 30

Thread: QThread exec proplem to stop...

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #11
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    8
    Thanked 541 Times in 521 Posts

    Default Re: QThread exec proplem to stop...

    Yes, exactly what I said.
    But Patrik's problem is that he cannot stop the thread .
    Everything works well ( he starts the event loop and all ), but the thread doesn't ever finish because he wasn't calling exit or quit anywhere.

    One has to call exec() within run() to start the event loop for the thread so that signals can be emitted.
    Not so sure about that. Signals can be emitted from within the thread to other threads - this works because the are nothing but some events. It is similar to calling QApplication: postEvent( someThread, someEvent ).

    Without it QHttp or any other class that uses events (signals included) won't function properly
    Yes, any event that targets this thread( without an event loop ) is a potential danger to the entire application ( therefore to other threads ).
    It happened to me - I was trying to create a pixmap( load it from disk ) in some thread that didn't have an event loop. But QPixmapCache( used internally by QPixmap ) sends timer events to the creator thread.
    This resulted in the GUI thread's event loop getting compromised ( most of the times stopped processing it's own events ).
    I am not sure if you remember it, but it was about the same time when I had problems with that crash in QProgressDialog.
    Anyway, to make a long story short ( too late, I guess ), signals can be emitted from threads without event handlers but the other way around is not safe at all - actually it won't work( since we're talking about queued connection ).

    Please note that this doesn't concern the finished() signal as it is emitted from the parent (where QThread object was created) thread.
    Good to know that.

    Regards

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

    patrik08 (20th May 2007)

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.