[Development] Opinions on QTBUG-71545

Konstantin Shegunov kshegunov at gmail.com
Mon Nov 5 23:41:18 CET 2018

On Mon, Nov 5, 2018 at 11:02 PM Elvis Stansvik <elvstone at gmail.com> wrote:

> But seems to me it would be a slippery slope to accept more
> exceptions.

You say exception, but I say expected behavior, which is actually the crux
of the disagreement.

> What's next, will I have to implement the destruction
> myself in my own widgets? :)

Yes, in the general case you actually have to if your dependent objects are
attached to a QObject holding an application-global state. Which is exactly
what Q*Application is - a QObject that has/is a global state.

On Mon, Nov 5, 2018 at 11:50 PM Uwe Rathmann <Uwe.Rathmann at tigertal.de>

> The title of the bug report is about QCoreApplication, while the demo
> code is a QApplication - so I'm not 100% sure if I completely understood
> the discussion.

I'm at fault for not attaching the stack trace, but I'll try to explain.
Indeed the example code is for QApplication, the problem however manifests
whenever the destruction of said application object goes through. The
segfault happens because QCoreApplication sets its static member - the
global instance of the application object - to null before the children are
cleaned up by the QObject destructor. This means that objects parented to
the application are destroyed after there's Q*Application object no more.

But at least for QApplication I would consider having children being
> common practice and actually Qt does this too:


Interesting point, I haven't thought about it.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/development/attachments/20181106/96ecd9a6/attachment.html>

More information about the Development mailing list