forked from quickshell/quickshell
service/tray: report misbehaving tray hosts
I've debugged broken tray items that just end up being a bad host far too many times.
This commit is contained in:
parent
0445eee33a
commit
36d1dbeb69
6 changed files with 25 additions and 2 deletions
|
@ -268,14 +268,15 @@ void DBusPropertyGroup::updateAllViaGetAll() {
|
|||
qCWarning(logDbusProperties).noquote()
|
||||
<< "Error updating properties of" << this->toString() << "via GetAll";
|
||||
qCWarning(logDbusProperties) << reply.error();
|
||||
emit this->getAllFailed(reply.error());
|
||||
} else {
|
||||
qCDebug(logDbusProperties).noquote()
|
||||
<< "Received GetAll property set for" << this->toString();
|
||||
this->updatePropertySet(reply.value(), true);
|
||||
emit this->getAllFinished();
|
||||
}
|
||||
|
||||
delete call;
|
||||
emit this->getAllFinished();
|
||||
};
|
||||
|
||||
QObject::connect(call, &QDBusPendingCallWatcher::finished, this, responseCallback);
|
||||
|
|
|
@ -135,6 +135,7 @@ public:
|
|||
|
||||
signals:
|
||||
void getAllFinished();
|
||||
void getAllFailed(QDBusError error);
|
||||
|
||||
private slots:
|
||||
void onPropertiesChanged(
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#include "dbus_item.h"
|
||||
#include "dbus_item_types.hpp"
|
||||
#include "host.hpp"
|
||||
#include "watcher.hpp"
|
||||
|
||||
using namespace qs::dbus;
|
||||
using namespace qs::dbus::dbusmenu;
|
||||
|
@ -76,6 +77,7 @@ StatusNotifierItem::StatusNotifierItem(const QString& address, QObject* parent)
|
|||
QObject::connect(&this->overlayIconPixmaps, &AbstractDBusProperty::changed, this, &StatusNotifierItem::updateIcon);
|
||||
|
||||
QObject::connect(&this->properties, &DBusPropertyGroup::getAllFinished, this, &StatusNotifierItem::onGetAllFinished);
|
||||
QObject::connect(&this->properties, &DBusPropertyGroup::getAllFailed, this, &StatusNotifierItem::onGetAllFailed);
|
||||
QObject::connect(&this->menuPath, &AbstractDBusProperty::changed, this, &StatusNotifierItem::onMenuPathChanged);
|
||||
// clang-format on
|
||||
|
||||
|
@ -246,6 +248,19 @@ void StatusNotifierItem::onGetAllFinished() {
|
|||
emit this->ready();
|
||||
}
|
||||
|
||||
void StatusNotifierItem::onGetAllFailed() {
|
||||
// Not changing the item to ready, as it is almost definitely broken.
|
||||
if (!this->mReady) {
|
||||
qWarning(logStatusNotifierItem) << "Failed to load tray item" << this->properties.toString();
|
||||
|
||||
if (!StatusNotifierWatcher::instance()->isRegistered()) {
|
||||
qWarning(logStatusNotifierItem)
|
||||
<< "Another StatusNotifier host seems to be running. Please disable it and check that "
|
||||
"the problem persists before reporting an issue.";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TrayImageHandle::TrayImageHandle(StatusNotifierItem* item)
|
||||
: QsImageHandle(QQmlImageProviderBase::Pixmap, item)
|
||||
, item(item) {}
|
||||
|
@ -257,6 +272,7 @@ TrayImageHandle::requestPixmap(const QString& /*unused*/, QSize* size, const QSi
|
|||
|
||||
auto pixmap = this->item->createPixmap(targetSize);
|
||||
if (pixmap.isNull()) {
|
||||
qCWarning(logStatusNotifierItem) << "Unable to create pixmap for tray icon" << this->item;
|
||||
pixmap = IconImageProvider::missingPixmap(targetSize);
|
||||
}
|
||||
|
||||
|
|
|
@ -75,6 +75,7 @@ signals:
|
|||
private slots:
|
||||
void updateIcon();
|
||||
void onGetAllFinished();
|
||||
void onGetAllFailed();
|
||||
void onMenuPathChanged();
|
||||
|
||||
private:
|
||||
|
|
|
@ -47,12 +47,15 @@ StatusNotifierWatcher::StatusNotifierWatcher(QObject* parent): QObject(parent) {
|
|||
this->tryRegister();
|
||||
}
|
||||
|
||||
bool StatusNotifierWatcher::isRegistered() const { return this->registered; }
|
||||
|
||||
void StatusNotifierWatcher::tryRegister() { // NOLINT
|
||||
auto bus = QDBusConnection::sessionBus();
|
||||
auto success = bus.registerService("org.kde.StatusNotifierWatcher");
|
||||
|
||||
if (success) {
|
||||
qCDebug(logStatusNotifierWatcher) << "Registered watcher at org.kde.StatusNotifierWatcher";
|
||||
this->registered = true;
|
||||
} else {
|
||||
qCDebug(logStatusNotifierWatcher)
|
||||
<< "Could not register watcher at org.kde.StatusNotifierWatcher, presumably because one is "
|
||||
|
@ -68,7 +71,6 @@ void StatusNotifierWatcher::onServiceUnregistered(const QString& service) {
|
|||
<< "Active StatusNotifierWatcher unregistered, attempting registration";
|
||||
this->tryRegister();
|
||||
return;
|
||||
;
|
||||
} else {
|
||||
QString qualifiedItem;
|
||||
this->items.removeIf([&](const QString& item) {
|
||||
|
|
|
@ -29,6 +29,7 @@ public:
|
|||
[[nodiscard]] qint32 protocolVersion() const { return 0; } // NOLINT
|
||||
[[nodiscard]] bool isHostRegistered() const;
|
||||
[[nodiscard]] QList<QString> registeredItems() const;
|
||||
[[nodiscard]] bool isRegistered() const;
|
||||
|
||||
// NOLINTBEGIN
|
||||
void RegisterStatusNotifierHost(const QString& host);
|
||||
|
@ -54,6 +55,7 @@ private:
|
|||
QDBusServiceWatcher serviceWatcher;
|
||||
QList<QString> hosts;
|
||||
QList<QString> items;
|
||||
bool registered = false;
|
||||
};
|
||||
|
||||
} // namespace qs::service::sni
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue