fix(Tray): add item if not exist

This commit is contained in:
Alex 2019-05-13 14:27:01 +02:00
parent db14fac038
commit b54160e02f
2 changed files with 11 additions and 4 deletions

View File

@ -130,8 +130,13 @@ std::tuple<std::string, std::string> Host::getBusNameAndObjectPath(const std::st
void Host::addRegisteredItem(std::string service) {
auto [bus_name, object_path] = getBusNameAndObjectPath(service);
auto it = std::find_if(items_.begin(), items_.end(), [&bus_name, &object_path](const auto& item) {
return bus_name == item->bus_name && object_path == item->object_path;
});
if (it == items_.end()) {
items_.emplace_back(new Item(bus_name, object_path, config_));
on_add_(items_.back());
}
}
} // namespace waybar::modules::SNI

View File

@ -28,7 +28,9 @@ Watcher::~Watcher() {
g_slist_free_full(items_, gfWatchFree);
items_ = nullptr;
}
g_dbus_interface_skeleton_unexport(G_DBUS_INTERFACE_SKELETON(watcher_));
auto iface = G_DBUS_INTERFACE_SKELETON(watcher_);
auto conn = g_dbus_interface_skeleton_get_connection(iface);
g_dbus_interface_skeleton_unexport_from_connection(iface, conn);
}
void Watcher::busAcquired(const Glib::RefPtr<Gio::DBus::Connection>& conn, Glib::ustring name) {