mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Fix restart before exec on macOS.
This commit is contained in:
parent
6eaeb306d6
commit
9b2d080e8e
3 changed files with 20 additions and 2 deletions
|
@ -1079,7 +1079,7 @@ void Application::QuitAttempt() {
|
||||||
if (!IsAppLaunched()
|
if (!IsAppLaunched()
|
||||||
|| Sandbox::Instance().isSavingSession()
|
|| Sandbox::Instance().isSavingSession()
|
||||||
|| App().readyToQuit()) {
|
|| App().readyToQuit()) {
|
||||||
QApplication::quit();
|
Sandbox::QuitWhenStarted();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1115,7 +1115,7 @@ void Application::quitPreventFinished() {
|
||||||
|
|
||||||
void Application::quitDelayed() {
|
void Application::quitDelayed() {
|
||||||
if (!_private->quitTimer.isActive()) {
|
if (!_private->quitTimer.isActive()) {
|
||||||
_private->quitTimer.setCallback([] { QApplication::quit(); });
|
_private->quitTimer.setCallback([] { Sandbox::QuitWhenStarted(); });
|
||||||
_private->quitTimer.callOnce(kQuitPreventTimeoutMs);
|
_private->quitTimer.callOnce(kQuitPreventTimeoutMs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -78,6 +78,8 @@ QString _escapeFrom7bit(const QString &str) {
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
|
bool Sandbox::QuitOnStartRequested = false;
|
||||||
|
|
||||||
Sandbox::Sandbox(
|
Sandbox::Sandbox(
|
||||||
not_null<Core::Launcher*> launcher,
|
not_null<Core::Launcher*> launcher,
|
||||||
int &argc,
|
int &argc,
|
||||||
|
@ -155,9 +157,22 @@ int Sandbox::start() {
|
||||||
_localSocket.connectToServer(_localServerName);
|
_localSocket.connectToServer(_localServerName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (QuitOnStartRequested) {
|
||||||
|
closeApplication();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
_started = true;
|
||||||
return exec();
|
return exec();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Sandbox::QuitWhenStarted() {
|
||||||
|
if (!QApplication::instance() || !Instance()._started) {
|
||||||
|
QuitOnStartRequested = true;
|
||||||
|
} else {
|
||||||
|
quit();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Sandbox::launchApplication() {
|
void Sandbox::launchApplication() {
|
||||||
InvokeQueued(this, [=] {
|
InvokeQueued(this, [=] {
|
||||||
if (App::quitting()) {
|
if (App::quitting()) {
|
||||||
|
|
|
@ -60,6 +60,7 @@ public:
|
||||||
|
|
||||||
return *static_cast<Sandbox*>(QCoreApplication::instance());
|
return *static_cast<Sandbox*>(QCoreApplication::instance());
|
||||||
}
|
}
|
||||||
|
static void QuitWhenStarted();
|
||||||
|
|
||||||
~Sandbox();
|
~Sandbox();
|
||||||
|
|
||||||
|
@ -119,6 +120,8 @@ private:
|
||||||
QLocalSocket _localSocket;
|
QLocalSocket _localSocket;
|
||||||
LocalClients _localClients;
|
LocalClients _localClients;
|
||||||
bool _secondInstance = false;
|
bool _secondInstance = false;
|
||||||
|
bool _started = false;
|
||||||
|
static bool QuitOnStartRequested;
|
||||||
|
|
||||||
std::unique_ptr<UpdateChecker> _updateChecker;
|
std::unique_ptr<UpdateChecker> _updateChecker;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue