From c923d47a0a6526f2d55860fd465bd7d0d4bba2a1 Mon Sep 17 00:00:00 2001 From: Andrea Azzarone Date: Fri, 12 Oct 2012 12:39:33 +0200 Subject: Unregister gdbus object in the dtor. (bzr r2831.3.1) --- launcher/LauncherController.cpp | 19 +++++++++++++------ launcher/LauncherControllerPrivate.h | 4 +++- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/launcher/LauncherController.cpp b/launcher/LauncherController.cpp index b64884493..4e7c71ff0 100644 --- a/launcher/LauncherController.cpp +++ b/launcher/LauncherController.cpp @@ -112,6 +112,8 @@ Controller::Impl::Impl(Controller* parent) , launcher_key_press_time_(0) , dbus_owner_(g_bus_own_name(G_BUS_TYPE_SESSION, DBUS_NAME.c_str(), G_BUS_NAME_OWNER_FLAGS_NONE, OnBusAcquired, nullptr, nullptr, this, nullptr)) + , gdbus_connection_(nullptr) + , reg_id_(0) { edge_barriers_.options = parent_->options(); @@ -164,6 +166,9 @@ Controller::Impl::~Impl() launcher_ptr->GetParent()->UnReference(); } + if (gdbus_connection_ && reg_id_) + g_dbus_connection_unregister_object(gdbus_connection_, reg_id_); + g_bus_unown_name(dbus_owner_); } @@ -1408,7 +1413,6 @@ void Controller::Impl::ReceiveLauncherKeyPress(unsigned long eventType, void Controller::Impl::OnBusAcquired(GDBusConnection* connection, const gchar* name, gpointer user_data) { GDBusNodeInfo* introspection_data = g_dbus_node_info_new_for_xml(DBUS_INTROSPECTION.c_str(), nullptr); - unsigned int reg_id; if (!introspection_data) { @@ -1416,11 +1420,14 @@ void Controller::Impl::OnBusAcquired(GDBusConnection* connection, const gchar* n return; } - reg_id = g_dbus_connection_register_object(connection, DBUS_PATH.c_str(), - introspection_data->interfaces[0], - &interface_vtable, user_data, - nullptr, nullptr); - if (!reg_id) + auto self = static_cast(user_data); + + self->gdbus_connection_ = connection; + self->reg_id_ = g_dbus_connection_register_object(connection, DBUS_PATH.c_str(), + introspection_data->interfaces[0], + &interface_vtable, user_data, + nullptr, nullptr); + if (!self->reg_id_) { LOG_WARNING(logger) << "Object registration failed. Won't get dynamic launcher addition."; } diff --git a/launcher/LauncherControllerPrivate.h b/launcher/LauncherControllerPrivate.h index 708c7415f..181d7a2f0 100644 --- a/launcher/LauncherControllerPrivate.h +++ b/launcher/LauncherControllerPrivate.h @@ -135,8 +135,10 @@ public: int reactivate_index; bool keynav_restore_window_; int launcher_key_press_time_; - unsigned dbus_owner_; + unsigned dbus_owner_; + GDBusConnection* gdbus_connection_; + unsigned reg_id_; glib::Signal view_opened_signal_; glib::SourceManager sources_; -- cgit v1.2.3