Don't hold a dbus connection unecessarily in main window

This commit is contained in:
Ilya Fedin 2022-03-01 05:49:09 +04:00 committed by John Preston
parent 805e6de1dc
commit 8db567ba7a

View file

@ -408,10 +408,6 @@ uint djbStringHash(const std::string &string) {
class MainWindow::Private { class MainWindow::Private {
public: public:
base::unique_qptr<Ui::PopupMenu> trayIconMenuXEmbed; base::unique_qptr<Ui::PopupMenu> trayIconMenuXEmbed;
#ifndef DESKTOP_APP_DISABLE_DBUS_INTEGRATION
Glib::RefPtr<Gio::DBus::Connection> dbusConnection;
#endif // !DESKTOP_APP_DISABLE_DBUS_INTEGRATION
}; };
MainWindow::MainWindow(not_null<Window::Controller*> controller) MainWindow::MainWindow(not_null<Window::Controller*> controller)
@ -442,12 +438,6 @@ void MainWindow::initHook() {
}); });
#ifndef DESKTOP_APP_DISABLE_DBUS_INTEGRATION #ifndef DESKTOP_APP_DISABLE_DBUS_INTEGRATION
try {
_private->dbusConnection = Gio::DBus::Connection::get_sync(
Gio::DBus::BusType::BUS_TYPE_SESSION);
} catch (...) {
}
if (UseUnityCounter()) { if (UseUnityCounter()) {
LOG(("Using Unity launcher counter.")); LOG(("Using Unity launcher counter."));
} else { } else {
@ -541,18 +531,19 @@ void MainWindow::updateIconCounters() {
} }
try { try {
if (_private->dbusConnection) { const auto connection = Gio::DBus::Connection::get_sync(
_private->dbusConnection->emit_signal( Gio::DBus::BusType::BUS_TYPE_SESSION);
"/com/canonical/unity/launcherentry/"
+ std::to_string(djbStringHash(launcherUrl)), connection->emit_signal(
"com.canonical.Unity.LauncherEntry", "/com/canonical/unity/launcherentry/"
"Update", + std::to_string(djbStringHash(launcherUrl)),
{}, "com.canonical.Unity.LauncherEntry",
base::Platform::MakeGlibVariant(std::tuple{ "Update",
launcherUrl, {},
dbusUnityProperties, base::Platform::MakeGlibVariant(std::tuple{
})); launcherUrl,
} dbusUnityProperties,
}));
} catch (...) { } catch (...) {
} }
} }