mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Fix race condition between GApplication and GNotification
This commit is contained in:
parent
51cd07945b
commit
d6ed23b3dd
2 changed files with 22 additions and 2 deletions
|
@ -821,6 +821,8 @@ bool ByDefault() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Create(Window::Notifications::System *system) {
|
void Create(Window::Notifications::System *system) {
|
||||||
|
static auto ServiceWatcher = CreateServiceWatcher();
|
||||||
|
|
||||||
const auto managerSetter = [=] {
|
const auto managerSetter = [=] {
|
||||||
using ManagerType = Window::Notifications::ManagerType;
|
using ManagerType = Window::Notifications::ManagerType;
|
||||||
if ((Core::App().settings().nativeNotifications() || Enforced())
|
if ((Core::App().settings().nativeNotifications() || Enforced())
|
||||||
|
@ -839,21 +841,34 @@ void Create(Window::Notifications::System *system) {
|
||||||
};
|
};
|
||||||
|
|
||||||
if (Gio::Application::get_default()) {
|
if (Gio::Application::get_default()) {
|
||||||
|
ServiceWatcher = nullptr;
|
||||||
|
ServiceRegistered = false;
|
||||||
|
CurrentServerInformation = std::nullopt;
|
||||||
|
CurrentCapabilities = QStringList{};
|
||||||
managerSetter();
|
managerSetter();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const auto ServiceWatcher = CreateServiceWatcher();
|
|
||||||
|
|
||||||
const auto counter = std::make_shared<int>(2);
|
const auto counter = std::make_shared<int>(2);
|
||||||
const auto oneReady = [=] {
|
const auto oneReady = [=] {
|
||||||
if (!--*counter) {
|
if (!--*counter) {
|
||||||
|
// GApplication may be created while the reply is received
|
||||||
|
if (Gio::Application::get_default()) {
|
||||||
|
Core::App().notifications().createManager();
|
||||||
|
return;
|
||||||
|
}
|
||||||
managerSetter();
|
managerSetter();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// snap doesn't allow access when the daemon is not running :(
|
// snap doesn't allow access when the daemon is not running :(
|
||||||
StartServiceAsync([=] {
|
StartServiceAsync([=] {
|
||||||
|
// GApplication may be created while the reply is received
|
||||||
|
if (Gio::Application::get_default()) {
|
||||||
|
Core::App().notifications().createManager();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
ServiceRegistered = GetServiceRegistered();
|
ServiceRegistered = GetServiceRegistered();
|
||||||
|
|
||||||
if (!ServiceRegistered) {
|
if (!ServiceRegistered) {
|
||||||
|
|
|
@ -291,6 +291,11 @@ void LaunchGApplication() {
|
||||||
nullptr)));
|
nullptr)));
|
||||||
|
|
||||||
app->signal_startup().connect([=] {
|
app->signal_startup().connect([=] {
|
||||||
|
// GNotification
|
||||||
|
InvokeQueued(qApp, [] {
|
||||||
|
Core::App().notifications().createManager();
|
||||||
|
});
|
||||||
|
|
||||||
QEventLoop loop;
|
QEventLoop loop;
|
||||||
loop.exec(QEventLoop::ApplicationExec);
|
loop.exec(QEventLoop::ApplicationExec);
|
||||||
app->quit();
|
app->quit();
|
||||||
|
|
Loading…
Add table
Reference in a new issue