Reply a meaningful dBus error when detecting unmanaged windows

Currently, the method `createErrorReply()` with empty strings
errors out and the client gets no answer:
```
QDBusConnection: error: could not send error message to service "":
Error name cannot be empty
```

Simple test:
qdbus org.kde.KWin /KWin org.kde.KWin.showDebugConsole
qdbus org.kde.KWin /KWin org.kde.KWin.queryWindowInfo

Error name uses D-Bus Interface-like notation as suggested in
https://doc.qt.io/qt-5/qdbuserror.html#name

CCBUG: 340477
This commit is contained in:
Ismael Asensio 2020-10-26 23:27:54 +01:00
parent e5b2fca409
commit f397f072df

View file

@ -219,7 +219,9 @@ QVariantMap DBusInterface::queryWindowInfo()
if (auto c = qobject_cast<AbstractClient*>(t)) {
QDBusConnection::sessionBus().send(m_replyQueryWindowInfo.createReply(clientToVariantMap(c)));
} else {
QDBusConnection::sessionBus().send(m_replyQueryWindowInfo.createErrorReply(QString(), QString()));
QDBusConnection::sessionBus().send(m_replyQueryWindowInfo.createErrorReply(
QStringLiteral("org.kde.KWin.Error.InvalidWindow"),
QStringLiteral("Tried to query information about an unmanaged window")));
}
}
);