diff options
| author | Andrea Azzarone <azzaronea@gmail.com> | 2012-10-12 12:39:33 +0200 |
|---|---|---|
| committer | Andrea Azzarone <azzaronea@gmail.com> | 2012-10-12 12:39:33 +0200 |
| commit | c923d47a0a6526f2d55860fd465bd7d0d4bba2a1 (patch) | |
| tree | 776eab7379a40b973e5cd7f8201454f76757aa35 | |
| parent | ff8d1ba3bbca92d6df65e7c32e95a23813046c71 (diff) | |
Unregister gdbus object in the dtor.
(bzr r2831.3.1)
| -rw-r--r-- | launcher/LauncherController.cpp | 19 | ||||
| -rw-r--r-- | 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<Controller::Impl*>(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<void, BamfMatcher*, BamfView*> view_opened_signal_; glib::SourceManager sources_; |
