Results 1 to 4 of 4

Thread: deleteLater called from different thread (std::thread)

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts

    Default Re: deleteLater called from different thread (std::thread)

    deleteLater() post an event into the object thread's event loop using QCoreApplication:ostEvent(). That method is thread safe.

    Cheers,
    _

  2. #2
    Join Date
    Jun 2012
    Posts
    58
    Qt products
    Qt4
    Thanks
    13

    Default Re: deleteLater called from different thread (std::thread)

    oh, has anything changed or am i interpreting the documentation wrong? It says:
    ...for the object to be deleted, the control must return to the event loop from which deleteLater() was called.
    the thread from which deleteLater() was called (API thread) is not the same as thread in which QObject was created (GUI thread). So will deleteLater still post to the GUI thread?

  3. #3
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts

    Default Re: deleteLater called from different thread (std::thread)

    Maybe that is just an unfortunate phrasing, wanting to say that the thread executing the object's event processing must return to event processing before anything happens.

    I am pretty sure that QCoreApplication:ostEvent() puts the event in the target object's event loop, anything else wouldn't make sense.
    A quick check of the code confirms that :-)

    Cheers,
    _

  4. The following user says thank you to anda_skoa for this useful post:

    ustulation (24th November 2013)

Similar Threads

  1. Qt problem in postEvent,called from thread.
    By Raadush in forum Qt Programming
    Replies: 1
    Last Post: 23rd November 2012, 11:32
  2. Replies: 1
    Last Post: 25th October 2012, 16:10
  3. slot in worker thread is not called
    By phenoboy in forum Qt Programming
    Replies: 1
    Last Post: 2nd June 2012, 20:45
  4. Slot not getting called, Qt::ConnectionType, Thread
    By StarShaper in forum Qt Programming
    Replies: 3
    Last Post: 7th February 2012, 15:04
  5. Replies: 9
    Last Post: 28th November 2009, 21:31

Tags for this Thread

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.