fix(sni): retry Host proxy creation on transient errors
When Host::proxyReady fails to create the SnWatcher proxy (e.g. because the Watcher has not finished exporting /StatusNotifierWatcher yet), the cancellable is left set, causing nameAppeared to early-return on every subsequent event (see the // TODO marker). The Host is then stuck without a watcher, and the tray module reports 'No such object path /StatusNotifierWatcher' until the bar is fully restarted. Clear the cancellable on non-CANCELLED errors and schedule a single delayed retry of nameAppeared. The guard `watcher_ != nullptr` skips the retry if a parallel call already succeeded. Closes #3468
This commit is contained in:
@@ -6,6 +6,8 @@
|
|||||||
|
|
||||||
namespace waybar::modules::SNI {
|
namespace waybar::modules::SNI {
|
||||||
|
|
||||||
|
static const unsigned RETRY_DELAY_MS = 200;
|
||||||
|
|
||||||
Host::Host(const std::size_t id, const Json::Value& config, const Bar& bar,
|
Host::Host(const std::size_t id, const Json::Value& config, const Bar& bar,
|
||||||
const std::function<void(std::unique_ptr<Item>&)>& on_add,
|
const std::function<void(std::unique_ptr<Item>&)>& on_add,
|
||||||
const std::function<void(std::unique_ptr<Item>&)>& on_remove,
|
const std::function<void(std::unique_ptr<Item>&)>& on_remove,
|
||||||
@@ -72,11 +74,21 @@ void Host::proxyReady(GObject* src, GAsyncResult* res, gpointer data) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
auto host = static_cast<SNI::Host*>(data);
|
auto host = static_cast<SNI::Host*>(data);
|
||||||
host->watcher_ = watcher;
|
|
||||||
if (error != nullptr) {
|
if (error != nullptr) {
|
||||||
spdlog::error("Host: {}", error->message);
|
spdlog::error("Host: {}", error->message);
|
||||||
|
g_clear_object(&host->cancellable_);
|
||||||
|
Glib::signal_timeout().connect_once(
|
||||||
|
[host]() {
|
||||||
|
if (host->watcher_ != nullptr) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
auto conn = Gio::DBus::Connection::get_sync(Gio::DBus::BusType::BUS_TYPE_SESSION);
|
||||||
|
host->nameAppeared(conn, "org.kde.StatusNotifierWatcher", "");
|
||||||
|
},
|
||||||
|
RETRY_DELAY_MS);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
host->watcher_ = watcher;
|
||||||
sn_watcher_call_register_host(host->watcher_, host->object_path_.c_str(), host->cancellable_,
|
sn_watcher_call_register_host(host->watcher_, host->object_path_.c_str(), host->cancellable_,
|
||||||
&Host::registerHost, data);
|
&Host::registerHost, data);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user