Prefer invokeMethod on a function pointer

Rather than a char* that needs lookup at runtime.
This commit is contained in:
Aleix Pol 2022-10-16 01:00:24 +02:00 committed by Aleix Pol Gonzalez
parent 34b4352aac
commit d454a2981c
8 changed files with 17 additions and 12 deletions

View file

@ -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;
}

View file

@ -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()

View file

@ -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<QSocketNotifier> m_notifier;
QRecursiveMutex m_mutex;
std::deque<std::unique_ptr<Event>> m_eventQueue;

View file

@ -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)

View file

@ -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

View file

@ -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<NET::WindowType>();

View file

@ -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()

View file

@ -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()