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
1 changed files with 13 additions and 22 deletions

View File

@ -408,10 +408,6 @@ uint djbStringHash(const std::string &string) {
class MainWindow::Private {
public:
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)
@ -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 (...) {
}
}