From b9fc35845742346f1c45b90971de62a0b3e0fd0b Mon Sep 17 00:00:00 2001
From: Pea Nut <peanut2@systemli.org>
Date: Sat, 20 Jul 2024 13:22:40 +0200
Subject: [PATCH] Don't run Quit() twice during startup

`Quit()` in `main.cpp` calls `Quit()` in `gui/backend.go`
which calls `backend.Quit()` (`defined in pkg/backend/api.go`)

ways to test:
- Preferences -> Quit
- Systray -> Quit
- via signal: killall riseup-vpn

When we exit by Systray/Preferences, `QApplication::quit()` gets called
by `&Backend::quitDone` handler.
---
 gui/main.cpp | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/gui/main.cpp b/gui/main.cpp
index 7734a05e..ab8b340e 100644
--- a/gui/main.cpp
+++ b/gui/main.cpp
@@ -79,6 +79,7 @@ QList<QVariant> getAvailableLocales() {
 
 auto handler = [](int sig) -> void {
     printf("\nCatched signal(%d): quitting\n", sig);
+    Quit();
     QApplication::quit();
 };
 
@@ -112,11 +113,6 @@ int main(int argc, char **argv) {
     app.setQuitOnLastWindowClosed(false);
     app.setAttribute(Qt::AA_UseHighDpiPixmaps);
 
-    QObject::connect(&app, &QApplication::aboutToQuit, []() {
-            qDebug() << ">>> Quitting, bye!";
-            Quit();
-    });
-
 #ifdef OS_WIN
     signal(SIGINT, handler);
     signal(SIGTERM, handler);
-- 
GitLab