[Interest] [Development] [Q] Good way to handle QEvent::DeferredDelete
thiago.macieira at intel.com
Sat Dec 28 23:03:45 CET 2013
On sexta-feira, 27 de dezembro de 2013 11:23:39, Elvis Lee wrote:
> I'm looking for good way to handle objects which have called deleteLater.
> According to what I understood until now, there are 2 ways to handle them.
> One is making control return to the event loop. Another is calling
> QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete) explicitly.
The second alternative is not an option. Don't try to do that. Don't use event
types that are internal to Qt.
> Actually, for the first way, I couldn't know what to do exactly in code
> level. How to return control to event loop?
Add this to your code:
Really, it's just about returning. Return from the slots and from the event
> I feel the control is always on event loop in our module. Does that mean to
> exit from event loop in QCoreApplication::exec()?
No. That's returning control *to* exec() after it called your slots or event
> 1. What is the natural way to handle deleteLater?
Do nothing special. They are handled by Qt at the right time.
> 2. Where is a place which is not from QCoreApplication::notifyInternal
> so that it has loopLevel '1' to call sendPostedEvents?
Yes, but it's complex and, in my opinion, a design flaw. Something that I'd
wish we fixed.
PS: your question should have been sent to the interest@ mailing list. You're
not asking a question about Qt's own development. I'm cross-posting there.
Please remove dev@ from the Cc when replying.
Thiago Macieira - thiago.macieira (AT) intel.com
Software Architect - Intel Open Source Technology Center
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 190 bytes
Desc: This is a digitally signed message part.
More information about the Interest