Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[qtbase] Fix crash on exit when there are pending dbus calls. Contrib…
…utes to JB#52659

Stop the dbus connection manager thread when the QCoreApplication
instance is destroyed so it doesn't attempt to post events to a
destroyed event loop in the time between then and the QGlobalStatic
atexit cleanup function executing.
  • Loading branch information
denexter committed Jan 21, 2021
1 parent 567a894 commit e79c6d3
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/dbus/qdbusconnection.cpp
Expand Up @@ -68,6 +68,16 @@ static void preventDllUnload();

Q_GLOBAL_STATIC(QDBusConnectionManager, _q_manager)

static void shutdownConnectionManager()
{
if (_q_manager.exists()) {
auto manager = _q_manager();

manager->quit();
manager->wait();
}
}

struct QDBusConnectionManager::ConnectionRequestData
{
enum RequestType {
Expand Down Expand Up @@ -142,12 +152,12 @@ QDBusConnectionManager::QDBusConnectionManager()
#endif
defaultBuses[0] = defaultBuses[1] = Q_NULLPTR;
start();

qAddPostRoutine(shutdownConnectionManager);
}

QDBusConnectionManager::~QDBusConnectionManager()
{
quit();
wait();
}

QDBusConnectionManager* QDBusConnectionManager::instance()
Expand Down

0 comments on commit e79c6d3

Please sign in to comment.