From d454a2981c736fefaf153e82f0200da3c92588eb Mon Sep 17 00:00:00 2001 From: Aleix Pol Date: Sun, 16 Oct 2022 01:00:24 +0200 Subject: [PATCH] Prefer invokeMethod on a function pointer Rather than a char* that needs lookup at runtime. --- src/activities.cpp | 6 +++++- src/backends/libinput/connection.cpp | 2 +- src/backends/libinput/connection.h | 2 +- src/decorations/decoratedclient.cpp | 7 ++++++- src/globalshortcuts.cpp | 2 +- src/internalwindow.cpp | 6 +----- src/kcmkwin/kwinscreenedges/kwinscreenedge.cpp | 2 +- src/workspace.cpp | 2 +- 8 files changed, 17 insertions(+), 12 deletions(-) diff --git a/src/activities.cpp b/src/activities.cpp index 8f1e56f2b1..3316364d34 100644 --- a/src/activities.cpp +++ b/src/activities.cpp @@ -147,7 +147,11 @@ bool Activities::stop(const QString &id) } // ugly hack to avoid dbus deadlocks - QMetaObject::invokeMethod(this, "reallyStop", Qt::QueuedConnection, Q_ARG(QString, id)); + QMetaObject::invokeMethod( + this, [this, id] { + reallyStop(id); + }, + Qt::QueuedConnection); // then lie and assume it worked. return true; } diff --git a/src/backends/libinput/connection.cpp b/src/backends/libinput/connection.cpp index 2f234c600d..41af236455 100644 --- a/src/backends/libinput/connection.cpp +++ b/src/backends/libinput/connection.cpp @@ -114,7 +114,7 @@ Connection::~Connection() = default; void Connection::setup() { - QMetaObject::invokeMethod(this, "doSetup", Qt::QueuedConnection); + QMetaObject::invokeMethod(this, &Connection::doSetup, Qt::QueuedConnection); } void Connection::doSetup() diff --git a/src/backends/libinput/connection.h b/src/backends/libinput/connection.h index 425c68d0c5..4b4726eaec 100644 --- a/src/backends/libinput/connection.h +++ b/src/backends/libinput/connection.h @@ -66,7 +66,6 @@ Q_SIGNALS: void eventsRead(); private Q_SLOTS: - void doSetup(); void slotKGlobalSettingsNotifyChange(int type, int arg); private: @@ -74,6 +73,7 @@ private: void handleEvent(); void applyDeviceConfig(Device *device); void applyScreenToDevice(Device *device); + void doSetup(); std::unique_ptr m_notifier; QRecursiveMutex m_mutex; std::deque> m_eventQueue; diff --git a/src/decorations/decoratedclient.cpp b/src/decorations/decoratedclient.cpp index e1d3682f8a..34650f125a 100644 --- a/src/decorations/decoratedclient.cpp +++ b/src/decorations/decoratedclient.cpp @@ -211,7 +211,12 @@ void DecoratedClientImpl::showApplicationMenu(int actionId) void DecoratedClientImpl::requestToggleMaximization(Qt::MouseButtons buttons) { - QMetaObject::invokeMethod(this, "delayedRequestToggleMaximization", Qt::QueuedConnection, Q_ARG(Options::WindowOperation, options->operationMaxButtonClick(buttons))); + auto operation = options->operationMaxButtonClick(buttons); + QMetaObject::invokeMethod( + this, [this, operation] { + delayedRequestToggleMaximization(operation); + }, + Qt::QueuedConnection); } void DecoratedClientImpl::delayedRequestToggleMaximization(Options::WindowOperation operation) diff --git a/src/globalshortcuts.cpp b/src/globalshortcuts.cpp index 5e0eb7a272..68414aafda 100644 --- a/src/globalshortcuts.cpp +++ b/src/globalshortcuts.cpp @@ -86,7 +86,7 @@ QAction *GlobalShortcut::action() const void GlobalShortcut::invoke() const { - QMetaObject::invokeMethod(m_action, "trigger", Qt::QueuedConnection); + QMetaObject::invokeMethod(m_action, &QAction::trigger, Qt::QueuedConnection); } const Shortcut &GlobalShortcut::shortcut() const diff --git a/src/internalwindow.cpp b/src/internalwindow.cpp index 555156fab8..2c2e288b7e 100644 --- a/src/internalwindow.cpp +++ b/src/internalwindow.cpp @@ -120,11 +120,7 @@ bool InternalWindow::eventFilter(QObject *watched, QEvent *event) // Some dialog e.g. Plasma::Dialog may update shadow in the middle of rendering. // The opengl context changed by updateShadow may break the QML Window rendering // and cause crash. - QMetaObject::invokeMethod( - this, [this]() { - updateShadow(); - }, - Qt::QueuedConnection); + QMetaObject::invokeMethod(this, &InternalWindow::updateShadow, Qt::QueuedConnection); } if (pe->propertyName() == "kwin_windowType") { m_windowType = m_handle->property("kwin_windowType").value(); diff --git a/src/kcmkwin/kwinscreenedges/kwinscreenedge.cpp b/src/kcmkwin/kwinscreenedges/kwinscreenedge.cpp index a4fda24326..2813efef44 100644 --- a/src/kcmkwin/kwinscreenedges/kwinscreenedge.cpp +++ b/src/kcmkwin/kwinscreenedges/kwinscreenedge.cpp @@ -18,7 +18,7 @@ namespace KWin KWinScreenEdge::KWinScreenEdge(QWidget *parent) : QWidget(parent) { - QMetaObject::invokeMethod(this, "createConnection", Qt::QueuedConnection); + QMetaObject::invokeMethod(this, &KWinScreenEdge::createConnection, Qt::QueuedConnection); } KWinScreenEdge::~KWinScreenEdge() diff --git a/src/workspace.cpp b/src/workspace.cpp index 121e20ed2f..85ce1d7bca 100644 --- a/src/workspace.cpp +++ b/src/workspace.cpp @@ -270,7 +270,7 @@ void Workspace::init() } // broadcast that Workspace is ready, but first process all events. - QMetaObject::invokeMethod(this, "workspaceInitialized", Qt::QueuedConnection); + QMetaObject::invokeMethod(this, &Workspace::workspaceInitialized, Qt::QueuedConnection); // TODO: ungrabXServer()