From a429739f981149f109c9d58c4855abca7ebe10e8 Mon Sep 17 00:00:00 2001 From: Vlad Zahorodnii Date: Mon, 18 Apr 2022 11:24:28 +0300 Subject: [PATCH] Remove AbstractClient plumbing casts in DbusInterface --- src/dbusinterface.cpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/dbusinterface.cpp b/src/dbusinterface.cpp index 17a1f6f1f8..c560640a48 100644 --- a/src/dbusinterface.cpp +++ b/src/dbusinterface.cpp @@ -235,16 +235,18 @@ QVariantMap DBusInterface::queryWindowInfo() setDelayedReply(true); kwinApp()->platform()->startInteractiveWindowSelection( [this](AbstractClient *t) { - if (auto c = static_cast(t->isClient() ? t : nullptr)) { - QDBusConnection::sessionBus().send(m_replyQueryWindowInfo.createReply(clientToVariantMap(c))); - } else if (qobject_cast(t)) { - QDBusConnection::sessionBus().send(m_replyQueryWindowInfo.createErrorReply( - QStringLiteral("org.kde.KWin.Error.InvalidWindow"), - QStringLiteral("Tried to query information about an unmanaged window"))); - } else { + if (!t) { QDBusConnection::sessionBus().send(m_replyQueryWindowInfo.createErrorReply( QStringLiteral("org.kde.KWin.Error.UserCancel"), QStringLiteral("User cancelled the query"))); + return; + } + if (t->isClient()) { + QDBusConnection::sessionBus().send(m_replyQueryWindowInfo.createReply(clientToVariantMap(t))); + } else { + QDBusConnection::sessionBus().send(m_replyQueryWindowInfo.createErrorReply( + QStringLiteral("org.kde.KWin.Error.InvalidWindow"), + QStringLiteral("Tried to query information about an unmanaged window"))); } }); return QVariantMap{};