From 249984f4f93fe6fae81391f474e4d64ad9df3d6d Mon Sep 17 00:00:00 2001 From: Hennadii Stepanov <32963518+hebasto@users.noreply.github.com> Date: Sat, 16 Apr 2022 19:18:25 +0200 Subject: [PATCH 1/2] qt: Replace `GUIUtil::ObjectInvoke()` with `QMetaObject::invokeMethod()` The `GUIUtil::ObjectInvoke()` template function was a replacement of the `QMetaObject::invokeMethod()` functor overload which is available in Qt 5.10+. No behavior change. --- src/qt/initexecutor.cpp | 6 +++--- src/qt/walletcontroller.cpp | 3 ++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/qt/initexecutor.cpp b/src/qt/initexecutor.cpp index 24ae7ba73d3..d269dfec71e 100644 --- a/src/qt/initexecutor.cpp +++ b/src/qt/initexecutor.cpp @@ -5,13 +5,13 @@ #include #include -#include #include #include #include #include +#include #include #include #include @@ -39,7 +39,7 @@ void InitExecutor::handleRunawayException(const std::exception* e) void InitExecutor::initialize() { - GUIUtil::ObjectInvoke(&m_context, [this] { + QMetaObject::invokeMethod(&m_context, [this] { try { util::ThreadRename("qt-init"); qDebug() << "Running initialization in thread"; @@ -56,7 +56,7 @@ void InitExecutor::initialize() void InitExecutor::shutdown() { - GUIUtil::ObjectInvoke(&m_context, [this] { + QMetaObject::invokeMethod(&m_context, [this] { try { qDebug() << "Running Shutdown in thread"; m_node.appShutdown(); diff --git a/src/qt/walletcontroller.cpp b/src/qt/walletcontroller.cpp index b025bb367c7..d27ddf1aba5 100644 --- a/src/qt/walletcontroller.cpp +++ b/src/qt/walletcontroller.cpp @@ -24,6 +24,7 @@ #include #include +#include #include #include #include @@ -135,7 +136,7 @@ WalletModel* WalletController::getOrCreateWallet(std::unique_ptrmoveToThread(thread()); // setParent(parent) must be called in the thread which created the parent object. More details in #18948. - GUIUtil::ObjectInvoke(this, [wallet_model, this] { + QMetaObject::invokeMethod(this, [wallet_model, this] { wallet_model->setParent(this); }, GUIUtil::blockingGUIThreadConnection()); From 6958a26aa136e0976870237ccc6ea015d113f7ac Mon Sep 17 00:00:00 2001 From: Hennadii Stepanov <32963518+hebasto@users.noreply.github.com> Date: Sat, 16 Apr 2022 19:18:54 +0200 Subject: [PATCH 2/2] Revert "qt: Add ObjectInvoke template function" This reverts commit 5659e73493fcdfb5d0cb9d686c24c4fbe1c217ed. --- src/qt/guiutil.h | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/src/qt/guiutil.h b/src/qt/guiutil.h index 76e5207d816..e38ac6026a2 100644 --- a/src/qt/guiutil.h +++ b/src/qt/guiutil.h @@ -361,18 +361,6 @@ namespace GUIUtil #endif } - /** - * Queue a function to run in an object's event loop. This can be - * replaced by a call to the QMetaObject::invokeMethod functor overload after Qt 5.10, but - * for now use a QObject::connect for compatibility with older Qt versions, based on - * https://stackoverflow.com/questions/21646467/how-to-execute-a-functor-or-a-lambda-in-a-given-thread-in-qt-gcd-style - */ - template - void ObjectInvoke(QObject* object, Fn&& function, Qt::ConnectionType connection = Qt::QueuedConnection) - { - QObject source; - QObject::connect(&source, &QObject::destroyed, object, std::forward(function), connection); - } /** * Replaces a plain text link with an HTML tagged one.