[Interest] Segmentation fault on exiting Qt event loop

Ramakanth Kesireddy rama.kesi at gmail.com
Mon Dec 17 18:00:06 CET 2018


Yes we do have Qt running in worker thread(pthread)..Does it throws
segmentation fault if we donot wait for the thread(like pthread::join) to
exit event loop and destroy objects accordingly?

On Mon, 17 Dec, 2018, 17:00 Konstantin Shegunov <kshegunov at gmail.com wrote:

> On Mon, Dec 17, 2018 at 1:26 PM Andrew Ialacci <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/61e31bbc/attachment.html>


More information about the Interest mailing list