[Interest] Segmentation fault on exiting Qt event loop

Konstantin Shegunov kshegunov at gmail.com
Wed Dec 19 07:33:12 CET 2018

On Tue, Dec 18, 2018 at 8:25 AM Ramakanth Kesireddy <rama.kesi at gmail.com>

> Thanks for your mail..Yes did try with valgrind but couldn't detect memory
> issue may be due to the way our app is designed using threading.
> But wondering why it throws segmentation fault if qApp instance is created
> on stack but not on Heap as I understand that it is mandatory to construct
> qApp instance on stack by design.

QObject (and QCoreApplication) doesn't impose such a limitation, no, you
can have them in the heap or stack. I'd be really surprised, though, if you
don't get the same segfault at the point of the delete call. If you mean
that you just don't free it up, however, then that's a major code smell.
>From your description I'd hazard a guess that you have a QObject which
outlives the application (probably a global). This is not allowed, and as
Thiago already said you must clean up before the Q*Application's
destructor's run.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20181219/fa7776eb/attachment.html>

More information about the Interest mailing list