From e8e8e1082e8dea3ddecae98123156a24df96558d Mon Sep 17 00:00:00 2001 From: Ievgenii Meshcheriakov Date: Mon, 14 Aug 2023 17:24:00 +0200 Subject: [PATCH] QDBusConnectionManager: Register metatypes in the constructor Call QDBusMetaTypeId::init() in the cosntructor. This ensures that the custom metatype registry is not destroyed before the instance of the connection manager. Task-number: QTBUG-58732 Pick-to: 6.6 Change-Id: I8c7c4c23deab2c7e11c6389a8976666ccf6baf48 Reviewed-by: Qt CI Bot Reviewed-by: Thiago Macieira --- src/dbus/qdbusconnection.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/dbus/qdbusconnection.cpp b/src/dbus/qdbusconnection.cpp index 9ce13e769cc..baab2b8ca57 100644 --- a/src/dbus/qdbusconnection.cpp +++ b/src/dbus/qdbusconnection.cpp @@ -22,6 +22,7 @@ #include "qdbuspendingcall_p.h" #include "qdbusthreaddebug_p.h" +#include "qdbusmetatype_p.h" #include @@ -82,6 +83,13 @@ void QDBusConnectionManager::removeConnection(const QString &name) QDBusConnectionManager::QDBusConnectionManager() { + // Ensure that the custom metatype registry is created before the instance + // of this class. This will ensure that the registry is not destroyed before + // the connection manager at application exit (see also QTBUG-58732). This + // works with compilers that use mechanism similar to atexit() to call + // destructurs for global statics. + QDBusMetaTypeId::init(); + connect(this, &QDBusConnectionManager::connectionRequested, this, &QDBusConnectionManager::executeConnectionRequest, Qt::BlockingQueuedConnection); connect(this, &QDBusConnectionManager::serverRequested,