refactor: don't print an error when a watcher is already present

This commit is contained in:
Alex 2019-05-10 14:56:28 +02:00
parent 131dae5818
commit e4756cf24e

View File

@ -14,8 +14,8 @@ Watcher::Watcher()
watcher_(sn_watcher_skeleton_new()) {} watcher_(sn_watcher_skeleton_new()) {}
Watcher::~Watcher() { Watcher::~Watcher() {
if (bus_name_id_ > 0) { if (bus_name_id_ != 0) {
g_bus_unown_name(bus_name_id_); Gio::DBus::unown_name(bus_name_id_);
bus_name_id_ = 0; bus_name_id_ = 0;
} }
@ -36,7 +36,10 @@ void Watcher::busAcquired(const Glib::RefPtr<Gio::DBus::Connection>& conn, Glib:
g_dbus_interface_skeleton_export( g_dbus_interface_skeleton_export(
G_DBUS_INTERFACE_SKELETON(watcher_), conn->gobj(), "/StatusNotifierWatcher", &error); G_DBUS_INTERFACE_SKELETON(watcher_), conn->gobj(), "/StatusNotifierWatcher", &error);
if (error != nullptr) { if (error != nullptr) {
std::cerr << error->message << std::endl; // Don't print an error when a watcher is already present
if (error->code != 2) {
std::cerr << error->message << std::endl;
}
g_error_free(error); g_error_free(error);
return; return;
} }