[Interest] Segmentation fault on exiting Qt event loop

Andrew Ialacci andrew at dkai.dk
Mon Dec 17 12:39:57 CET 2018

Wow, Yes!

I forgot to include actually killing the threads first before checking if they are running. Oops…

Assuming each threads quit() is called and all operations are stopped in each thread correctly is using a loop and sleep still ok?

From: Konstantin Shegunov <kshegunov at gmail.com>
Date: Monday, December 17, 2018 at 12:30 PM
To: Andrew Ialacci <andrew at dkai.dk>
Cc: Ramakanth Kesireddy <rama.kesi at gmail.com>, Qt Interest <interest at qt-project.org>
Subject: Re: [Interest] Segmentation fault on exiting Qt event loop

On Mon, Dec 17, 2018 at 1:26 PM Andrew Ialacci <andrew at dkai.dk<mailto:andrew at dkai.dk>> wrote:
I’ve had this issue on Windows especially when destroying worker threads on an application exit.

Which you shouldn't do.

What I ended up doing was sleeping the main thread until each worker threads isRunning() return false;
I’d love to know if this is the //best// solution to this problem but from what I’ve found it works very well.

Nope. Call QThread::quit or QThread::requestInterruption (depending on whether you have a running event loop in the thread(s)). And wait for them with QThread::wait before allowing the QThread objects to be destroyed.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20181217/f322b471/attachment.html>

More information about the Interest mailing list