From 3ef514f8d3aa8f43bb0edfb48e6ac2b769b00eb2 Mon Sep 17 00:00:00 2001 From: Ievgenii Meshcheriakov Date: Fri, 28 Apr 2023 13:38:39 +0200 Subject: [PATCH] QtDBus: Use QMetaObject::invokeMethod instead of QTimer::singleShot Change-Id: I1a9ecdcb8df7804d13fdcf676fc12b1e0f6bddae Reviewed-by: Thiago Macieira --- src/dbus/qdbusconnection.cpp | 3 ++- src/dbus/qdbusintegrator.cpp | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/dbus/qdbusconnection.cpp b/src/dbus/qdbusconnection.cpp index af6604bf0fb..2203f047b1e 100644 --- a/src/dbus/qdbusconnection.cpp +++ b/src/dbus/qdbusconnection.cpp @@ -153,7 +153,8 @@ QDBusConnectionPrivate *QDBusConnectionManager::connectToBus(QDBusConnection::Bu if (suspendedDelivery && data.result->connection) { data.result->ref.ref(); QDBusConnectionDispatchEnabler *o = new QDBusConnectionDispatchEnabler(data.result); - QTimer::singleShot(0, o, SLOT(execute())); + QMetaObject::invokeMethod(o, &QDBusConnectionDispatchEnabler::execute, + Qt::QueuedConnection); o->moveToThread(qApp->thread()); // qApp was checked in the caller } return data.result; diff --git a/src/dbus/qdbusintegrator.cpp b/src/dbus/qdbusintegrator.cpp index 28fb32c531b..d4f61bf2f71 100644 --- a/src/dbus/qdbusintegrator.cpp +++ b/src/dbus/qdbusintegrator.cpp @@ -296,7 +296,7 @@ static void qDBusNewConnection(DBusServer *server, DBusConnection *connection, v newConnection->ref.ref(); QReadLocker serverLock(&serverConnection->lock); QDBusConnectionDispatchEnabler *o = new QDBusConnectionDispatchEnabler(newConnection); - QTimer::singleShot(0, o, SLOT(execute())); + QMetaObject::invokeMethod(o, &QDBusConnectionDispatchEnabler::execute, Qt::QueuedConnection); if (serverConnection->serverObject) o->moveToThread(serverConnection->serverObject->thread()); }