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 <qt_ci_bot@qt-project.org>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
Ievgenii Meshcheriakov 2023-08-14 17:24:00 +02:00
parent d48831612a
commit e8e8e1082e

View File

@ -22,6 +22,7 @@
#include "qdbuspendingcall_p.h"
#include "qdbusthreaddebug_p.h"
#include "qdbusmetatype_p.h"
#include <algorithm>
@ -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,