diff options
| author | Marco Trevisan (Treviño) <mail@3v1n0.net> | 2017-01-17 16:39:14 +0100 | 
|---|---|---|
| committer | Marco Trevisan (Treviño) <mail@3v1n0.net> | 2017-01-17 16:39:14 +0100 | 
| commit | 7292739013fa98ec1c2cee9c91b669d0b7e38d72 (patch) | |
| tree | 6b9d2318b5e5dd4ef33f1c004036206de261b4b1 /UnityCore | |
| parent | 9959f7f5df4e789f712d2586cd41afc1f0ce7883 (diff) | |
GnomeSessionManager: add gcancellable to instance and use it for calls with temporary proxies
This fixes various crashes when the session manager is destroyed while a temporary proxy call is still in progress, and the callback is called afterwards. (bzr r4217.2.2)
Diffstat (limited to 'UnityCore')
| -rw-r--r-- | UnityCore/GnomeSessionManager.cpp | 18 | ||||
| -rw-r--r-- | UnityCore/GnomeSessionManagerImpl.h | 1 | 
2 files changed, 10 insertions, 9 deletions
| diff --git a/UnityCore/GnomeSessionManager.cpp b/UnityCore/GnomeSessionManager.cpp index 1fc9981bc..13a650baa 100644 --- a/UnityCore/GnomeSessionManager.cpp +++ b/UnityCore/GnomeSessionManager.cpp @@ -130,7 +130,7 @@ GnomeManager::Impl::Impl(GnomeManager* manager, bool test_mode)  glib::Variant tmp(g_variant_get_child_value(variant, 1), glib::StealRef());  SetupLogin1Proxy(tmp.GetObjectPath()); - }); + }, cancellable_);  }  } @@ -424,7 +424,7 @@ void GnomeManager::Impl::CallGnomeSessionMethod(std::string const& method, GVari  if (cb)  cb(ret, e); - }); + }, cancellable_);  }  void GnomeManager::Impl::CallUPowerMethod(std::string const& method, glib::DBusProxy::ReplyCallback const& cb) @@ -443,7 +443,7 @@ void GnomeManager::Impl::CallUPowerMethod(std::string const& method, glib::DBusP  {  cb(ret);  } - }); + }, cancellable_);  }  void GnomeManager::Impl::CallLogindMethod(std::string const& method, GVariant* parameters, glib::DBusProxy::CallFinishedCallback const& cb) @@ -465,7 +465,7 @@ void GnomeManager::Impl::CallLogindMethod(std::string const& method, GVariant* p  {  cb(ret, e);  } - }); + }, cancellable_);  }  void GnomeManager::Impl::CallConsoleKitMethod(std::string const& method, GVariant* parameters) @@ -482,7 +482,7 @@ void GnomeManager::Impl::CallConsoleKitMethod(std::string const& method, GVarian  {  LOG_ERROR(logger) << "Fallback call failed: " << e.Message();  } - }); + }, cancellable_);  }  void GnomeManager::Impl::CallDisplayManagerSeatMethod(std::string const& method, GVariant* parameters) @@ -499,7 +499,7 @@ void GnomeManager::Impl::CallDisplayManagerSeatMethod(std::string const& method,  {  LOG_ERROR(logger) << "DisplayManager Seat call failed: " << e.Message();  } - }); + }, cancellable_);  }  void GnomeManager::Impl::LockScreen(bool prompt) @@ -552,7 +552,7 @@ bool GnomeManager::Impl::HasInhibitors()  glib::Variant inhibitors(g_dbus_connection_call_sync(bus, test_mode_ ? testing::DBUS_NAME.c_str() : "org.gnome.SessionManager",  "/org/gnome/SessionManager", "org.gnome.SessionManager",  "IsInhibited", g_variant_new("(u)", Inhibited::LOGOUT), nullptr, - G_DBUS_CALL_FLAGS_NONE, 500, nullptr, &error)); + G_DBUS_CALL_FLAGS_NONE, 500, cancellable_, &error));  if (error)  { @@ -600,7 +600,7 @@ bool GnomeManager::Impl::AutomaticLogin()  glib::Variant user_path(g_dbus_connection_call_sync(bus, "org.freedesktop.Accounts",  "/org/freedesktop/Accounts", "org.freedesktop.Accounts",  "FindUserByName", g_variant_new("(s)",g_get_user_name()), nullptr, - G_DBUS_CALL_FLAGS_NONE, 500, nullptr, &error)); + G_DBUS_CALL_FLAGS_NONE, 500, cancellable_, &error));  if (error)  { @@ -611,7 +611,7 @@ bool GnomeManager::Impl::AutomaticLogin()  glib::Variant autologin(g_dbus_connection_call_sync(bus, "org.freedesktop.Accounts",  user_path.GetObjectPath().c_str(), "org.freedesktop.DBus.Properties",  "Get", g_variant_new("(ss)", "org.freedesktop.Accounts.User", "AutomaticLogin"), nullptr, - G_DBUS_CALL_FLAGS_NONE, 500, nullptr, &error)); + G_DBUS_CALL_FLAGS_NONE, 500, cancellable_, &error));  if (error)  { diff --git a/UnityCore/GnomeSessionManagerImpl.h b/UnityCore/GnomeSessionManagerImpl.h index 6e25ef9d8..9eee96757 100644 --- a/UnityCore/GnomeSessionManagerImpl.h +++ b/UnityCore/GnomeSessionManagerImpl.h @@ -85,6 +85,7 @@ struct GnomeManager::Impl  glib::DBusProxy::Ptr dm_proxy_;  glib::DBusProxy::Ptr dm_seat_proxy_; + glib::Cancellable cancellable_;  int open_sessions_;  }; | 
