Port to function-pointer based QMetaObject::invokeMethod

It's more efficient and compile-time checked
This commit is contained in:
Kai Uwe Broulik 2021-09-06 21:11:02 +02:00 committed by David Edmundson
parent ed2d0979c7
commit 8bebf5cee1
8 changed files with 11 additions and 14 deletions

View file

@ -2334,7 +2334,7 @@ void AbstractClient::createDecoration(const QRect &oldGeometry)
{
KDecoration2::Decoration *decoration = Decoration::DecorationBridge::self()->createDecoration(this);
if (decoration) {
QMetaObject::invokeMethod(decoration, "update", Qt::QueuedConnection);
QMetaObject::invokeMethod(decoration, QOverload<>::of(&KDecoration2::Decoration::update), Qt::QueuedConnection);
connect(decoration, &KDecoration2::Decoration::shadowChanged, this, &Toplevel::updateShadow);
connect(decoration, &KDecoration2::Decoration::bordersChanged,
this, &AbstractClient::updateDecorationInputShape);

View file

@ -176,7 +176,7 @@ DELEGATE(requestMinimize, minimize)
void DecoratedClientImpl::requestClose()
{
QMetaObject::invokeMethod(m_client, "closeWindow", Qt::QueuedConnection);
QMetaObject::invokeMethod(m_client, &AbstractClient::closeWindow, Qt::QueuedConnection);
}
QColor DecoratedClientImpl::color(KDecoration2::ColorGroup group, KDecoration2::ColorRole role) const

View file

@ -254,7 +254,7 @@ private:
return;
}
m_dequeueScheduled = true;
QMetaObject::invokeMethod(this, "dequeue", Qt::QueuedConnection);
QMetaObject::invokeMethod(this, &AbstractEffectLoadQueue::dequeue, Qt::QueuedConnection);
}
Loader *m_effectLoader;
bool m_dequeueScheduled;

View file

@ -93,7 +93,7 @@ KCMKWinDecoration::KCMKWinDecoration(QObject *parent, const QVariantList &argume
.connect(QString(), QStringLiteral("/KWin"), QStringLiteral("org.kde.KWin"), QStringLiteral("reloadConfig"),
this, SLOT(reloadKWinSettings()));
QMetaObject::invokeMethod(m_themesModel, "init", Qt::QueuedConnection);
QMetaObject::invokeMethod(m_themesModel, &KDecoration2::Configuration::DecorationsModel::init, Qt::QueuedConnection);
}
KWinDecorationSettings *KCMKWinDecoration::settings() const
@ -103,7 +103,7 @@ KWinDecorationSettings *KCMKWinDecoration::settings() const
void KCMKWinDecoration::reloadKWinSettings()
{
QMetaObject::invokeMethod(m_themesModel, "init", Qt::QueuedConnection);
QMetaObject::invokeMethod(m_themesModel, &KDecoration2::Configuration::DecorationsModel::init, Qt::QueuedConnection);
}
void KCMKWinDecoration::load()

View file

@ -50,7 +50,7 @@ AnimationEffect::AnimationEffect() : d_ptr(new AnimationEffectPrivate())
s_clock.start();
/* this is the same as the QTimer::singleShot(0, SLOT(init())) kludge
* defering the init and esp. the connection to the windowClosed slot */
QMetaObject::invokeMethod( this, "init", Qt::QueuedConnection );
QMetaObject::invokeMethod(this, &AnimationEffect::init, Qt::QueuedConnection);
}
AnimationEffect::~AnimationEffect()

View file

@ -292,7 +292,7 @@ void X11StandalonePlatform::createOpenGLSafePoint(OpenGLSafePoint safePoint)
}, Qt::DirectConnection);
} else {
Q_ASSERT(m_openGLFreezeProtection);
QMetaObject::invokeMethod(m_openGLFreezeProtection, "start", Qt::QueuedConnection);
QMetaObject::invokeMethod(m_openGLFreezeProtection, QOverload<>::of(&QTimer::start), Qt::QueuedConnection);
}
break;
case OpenGLSafePoint::PostInit:
@ -301,7 +301,7 @@ void X11StandalonePlatform::createOpenGLSafePoint(OpenGLSafePoint safePoint)
// Deliberately continue with PostFrame
Q_FALLTHROUGH();
case OpenGLSafePoint::PostFrame:
QMetaObject::invokeMethod(m_openGLFreezeProtection, "stop", Qt::QueuedConnection);
QMetaObject::invokeMethod(m_openGLFreezeProtection, &QTimer::stop, Qt::QueuedConnection);
break;
case OpenGLSafePoint::PostLastGuardedFrame:
m_openGLFreezeProtection->deleteLater();

View file

@ -765,10 +765,7 @@ void UserActionsMenu::slotWindowOperation(QAction *action)
// need to delay performing the window operation as we need to have the
// user actions menu closed before we destroy the decoration. Otherwise Qt crashes
qRegisterMetaType<Options::WindowOperation>();
QMetaObject::invokeMethod(workspace(), "performWindowOperation",
Qt::QueuedConnection,
Q_ARG(KWin::AbstractClient*, c),
Q_ARG(Options::WindowOperation, op));
QMetaObject::invokeMethod(workspace(), std::bind(&Workspace::performWindowOperation, workspace(), c, op), Qt::QueuedConnection);
}
void UserActionsMenu::slotToggleOnActivity(QAction *action)
@ -1191,7 +1188,7 @@ void Workspace::performWindowOperation(AbstractClient* c, Options::WindowOperati
c->performMouseCommand(Options::MouseUnrestrictedResize, Cursors::self()->mouse()->pos());
break;
case Options::CloseOp:
QMetaObject::invokeMethod(c, "closeWindow", Qt::QueuedConnection);
QMetaObject::invokeMethod(c, &AbstractClient::closeWindow, Qt::QueuedConnection);
break;
case Options::MaximizeOp:
c->maximize(c->maximizeMode() == MaximizeFull

View file

@ -1117,7 +1117,7 @@ void X11Client::createDecoration(const QRect& oldgeom)
{
KDecoration2::Decoration *decoration = Decoration::DecorationBridge::self()->createDecoration(this);
if (decoration) {
QMetaObject::invokeMethod(decoration, "update", Qt::QueuedConnection);
QMetaObject::invokeMethod(decoration, QOverload<>::of(&KDecoration2::Decoration::update), Qt::QueuedConnection);
connect(decoration, &KDecoration2::Decoration::shadowChanged, this, &Toplevel::updateShadow);
connect(decoration, &KDecoration2::Decoration::bordersChanged,
this, &X11Client::updateDecorationInputShape);