From 8db567ba7a0eb4319ff1bd594d64ce023d0d0cd4 Mon Sep 17 00:00:00 2001 From: Ilya Fedin Date: Tue, 1 Mar 2022 05:49:09 +0400 Subject: [PATCH] Don't hold a dbus connection unecessarily in main window --- .../platform/linux/main_window_linux.cpp | 35 +++++++------------ 1 file changed, 13 insertions(+), 22 deletions(-) diff --git a/Telegram/SourceFiles/platform/linux/main_window_linux.cpp b/Telegram/SourceFiles/platform/linux/main_window_linux.cpp index 880ed72db7..5f6bee73bf 100644 --- a/Telegram/SourceFiles/platform/linux/main_window_linux.cpp +++ b/Telegram/SourceFiles/platform/linux/main_window_linux.cpp @@ -408,10 +408,6 @@ uint djbStringHash(const std::string &string) { class MainWindow::Private { public: base::unique_qptr trayIconMenuXEmbed; - -#ifndef DESKTOP_APP_DISABLE_DBUS_INTEGRATION - Glib::RefPtr dbusConnection; -#endif // !DESKTOP_APP_DISABLE_DBUS_INTEGRATION }; MainWindow::MainWindow(not_null controller) @@ -442,12 +438,6 @@ void MainWindow::initHook() { }); #ifndef DESKTOP_APP_DISABLE_DBUS_INTEGRATION - try { - _private->dbusConnection = Gio::DBus::Connection::get_sync( - Gio::DBus::BusType::BUS_TYPE_SESSION); - } catch (...) { - } - if (UseUnityCounter()) { LOG(("Using Unity launcher counter.")); } else { @@ -541,18 +531,19 @@ void MainWindow::updateIconCounters() { } try { - if (_private->dbusConnection) { - _private->dbusConnection->emit_signal( - "/com/canonical/unity/launcherentry/" - + std::to_string(djbStringHash(launcherUrl)), - "com.canonical.Unity.LauncherEntry", - "Update", - {}, - base::Platform::MakeGlibVariant(std::tuple{ - launcherUrl, - dbusUnityProperties, - })); - } + const auto connection = Gio::DBus::Connection::get_sync( + Gio::DBus::BusType::BUS_TYPE_SESSION); + + connection->emit_signal( + "/com/canonical/unity/launcherentry/" + + std::to_string(djbStringHash(launcherUrl)), + "com.canonical.Unity.LauncherEntry", + "Update", + {}, + base::Platform::MakeGlibVariant(std::tuple{ + launcherUrl, + dbusUnityProperties, + })); } catch (...) { } }