How to know is exist any events in queue?
-
Hello all!
I have two threads and several connections via signals and slots between.
I want to know is exist any signals in queue of thread object before I will delete it and if exist I want wait until all signals will handled by this object.
Is it possbile and how to do this if possible?Thank you for attention!
-
since you only could check if in the current event loop are pending events anyways, you can delete a QObject instance by QObject::deleteLater(). It will cause the object to be deleted in the next event loop iteration.
-
[quote author="raven-worx" date="1379934894"]since you only could check if in the current event loop are pending events anyways, you can delete a QObject instance by QObject::deleteLater(). It will cause the object to be deleted in the next event loop iteration.[/quote]
Problem that I don't can call @QObject::deleteLater()@ because I already want to check this in destructor of QThread object.
-
so how do come into your destructor?!
-
with what portion of code is your thread object deleted?!
Just use deleteLater() in this place and you wont need any checks, since deleteLater() ensures that it will be deleted in the next event loop iteration.
So your thread will receive all events from the current event loop iteration before it gets deleted.