[Interest] Widget event called after it has been deleted
Thiago Macieira
thiago.macieira at intel.com
Thu Sep 19 05:54:35 CEST 2013
On quarta-feira, 18 de setembro de 2013 23:54:17, Etienne Sandré-Chardonnal
wrote:
> Let me explain the problem differently:
> - widget A emits a signal
> - widget B has a slot which effectively deletes A (because
> QScrollArea::setWidget deletes its current widget) - I connected A's signal
> to B's slot (and this is meaningful in this GUI, because A has a button
> that tells B to go to the parent, which replaces the A widget for viewing
> current node's properties)
>
> Just done like that, it crashes. Because after deleting A, B's slot returns
> to A's meta-object signal code. Which is bad.
>
> Using a QueuedConnection would solve the issue. Because execution of A's
> signal would post an event for calling B's slot, then exit A's signal code,
> return to event loop, and exectute B's slot. Then it's safe to delete A.
> However, I do not like the stability of the program to rely on the type of
> connection. That's not in the essence of modularity with signal/slots.
>
> Thiago, if you read me, Could you confirm the above's statements?
You're correct.
Deleting the sender is almost always a bad idea.
--
Thiago Macieira - thiago.macieira (AT) intel.com
Software Architect - Intel Open Source Technology Center
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 190 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20130918/381d4c70/attachment.sig>
More information about the Interest
mailing list