mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Don't hold GApplication
That's a much better way to avoid defunct event loop that will work in any edge case Also don't assume GApplication is always running in Platform::Notifications::Enforced
This commit is contained in:
parent
78467b18f7
commit
f71e7812e6
2 changed files with 4 additions and 20 deletions
|
@ -830,7 +830,9 @@ bool Supported() {
|
||||||
bool Enforced() {
|
bool Enforced() {
|
||||||
// Wayland doesn't support positioning
|
// Wayland doesn't support positioning
|
||||||
// and custom notifications don't work here
|
// and custom notifications don't work here
|
||||||
return IsWayland() || Window::Notifications::OptionGNotification.value();
|
return IsWayland()
|
||||||
|
|| (Gio::Application::get_default()
|
||||||
|
&& Window::Notifications::OptionGNotification.value());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ByDefault() {
|
bool ByDefault() {
|
||||||
|
|
|
@ -245,22 +245,6 @@ void LaunchGApplication() {
|
||||||
.chopped(8)
|
.chopped(8)
|
||||||
.toStdString();
|
.toStdString();
|
||||||
|
|
||||||
const auto owned = [&] {
|
|
||||||
if (!Gio::Application::id_is_valid(appId)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
return base::Platform::DBus::NameHasOwner(
|
|
||||||
Gio::DBus::Connection::get_sync(
|
|
||||||
Gio::DBus::BusType::SESSION),
|
|
||||||
appId);
|
|
||||||
} catch (...) {
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}();
|
|
||||||
|
|
||||||
const auto app = Glib::wrap(
|
const auto app = Glib::wrap(
|
||||||
G_APPLICATION(
|
G_APPLICATION(
|
||||||
g_object_new(
|
g_object_new(
|
||||||
|
@ -270,8 +254,7 @@ void LaunchGApplication() {
|
||||||
? appId.c_str()
|
? appId.c_str()
|
||||||
: nullptr,
|
: nullptr,
|
||||||
"flags",
|
"flags",
|
||||||
G_APPLICATION_HANDLES_OPEN
|
G_APPLICATION_HANDLES_OPEN,
|
||||||
| (owned ? G_APPLICATION_NON_UNIQUE : 0),
|
|
||||||
nullptr)));
|
nullptr)));
|
||||||
|
|
||||||
app->signal_startup().connect([=] {
|
app->signal_startup().connect([=] {
|
||||||
|
@ -388,7 +371,6 @@ void LaunchGApplication() {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
app->hold();
|
|
||||||
app->run(0, nullptr);
|
app->run(0, nullptr);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue