Fix crash when Connection is closed while ItemRetriever is running

Authored by dvratil on Feb 24 2017, 4:22 PM.

Description

Fix crash when Connection is closed while ItemRetriever is running

ItemRetriever::exec() runs a nested QEventLoop. If the parent
Connection is terminated while the event loop is running, the
delayed AkThread::quit() invocation is executed and the thread
is destroyed, while technically there is still execution going
on. To workaround that issue we don't destroy the thread in
Connection::quit() if we detect a nested QEventLoop but instead
we just notify the event loop to quit and destroy the thread
later when execution returns back to ItemRetriever::slotNewData().

This fixes a crash in QPSQLQuery, which was dereferencing a
QPSQLDriver after the driver has been deleted as the thread was
destroyed and avoids more of random crashes due to the Connection
being virtually deleted from its own nested event loop.

BUG: 374734
FIXED-IN: 5.4.3

Details

Committed
dvratilFeb 24 2017, 4:22 PM
Parents
R165:5219f770b998: DataStream: throw exception if device is null
Branches
Unknown
Tags
Unknown