diff options
author | Saturneric <[email protected]> | 2022-06-01 15:12:20 +0000 |
---|---|---|
committer | Saturneric <[email protected]> | 2022-06-01 15:12:20 +0000 |
commit | 769465f1496439c2e7de4ffa9460b1f4a0fe5c2d (patch) | |
tree | 65addaec57c7382e998b0b603d8a6ff736616eae | |
parent | doc(manual): fix urls (diff) | |
download | GpgFrontend-769465f1496439c2e7de4ffa9460b1f4a0fe5c2d.tar.gz GpgFrontend-769465f1496439c2e7de4ffa9460b1f4a0fe5c2d.zip |
fix(ui): fix crash when start app.
-rw-r--r-- | src/ui/GpgFrontendApplication.cpp | 9 | ||||
-rw-r--r-- | src/ui/GpgFrontendApplication.h | 2 | ||||
-rw-r--r-- | src/ui/GpgFrontendUIInit.cpp | 3 |
3 files changed, 10 insertions, 4 deletions
diff --git a/src/ui/GpgFrontendApplication.cpp b/src/ui/GpgFrontendApplication.cpp index 4cb50b43..57b36152 100644 --- a/src/ui/GpgFrontendApplication.cpp +++ b/src/ui/GpgFrontendApplication.cpp @@ -30,7 +30,7 @@ namespace GpgFrontend::UI { -GpgFrontendApplication::GpgFrontendApplication(int &argc, char **argv) +GpgFrontendApplication::GpgFrontendApplication(int& argc, char *argv[]) : QApplication(argc, argv) { #ifndef MACOS this->setWindowIcon(QIcon(":gpgfrontend.png")); @@ -56,13 +56,18 @@ GpgFrontendApplication::GpgFrontendApplication(int &argc, char **argv) GpgFrontendApplication *GpgFrontendApplication::GetInstance(int argc, char *argv[], bool new_instance) { + static GpgFrontendApplication *instance = nullptr; + static int static_argc = argc; + static char **static_argv = argv; + if (new_instance || !instance) { if (instance != nullptr) { instance->quit(); delete instance; + } else { } - instance = new GpgFrontendApplication(argc, argv); + instance = new GpgFrontendApplication(static_argc, static_argv); } return instance; } diff --git a/src/ui/GpgFrontendApplication.h b/src/ui/GpgFrontendApplication.h index 52a0a610..caf0750d 100644 --- a/src/ui/GpgFrontendApplication.h +++ b/src/ui/GpgFrontendApplication.h @@ -40,7 +40,7 @@ class GPGFRONTEND_UI_EXPORT GpgFrontendApplication : public QApplication { * @param argc * @param argv */ - explicit GpgFrontendApplication(int &argc, char **argv); + explicit GpgFrontendApplication(int& argc, char *argv[]); /** * @brief Destroy the GpgFrontend Application object diff --git a/src/ui/GpgFrontendUIInit.cpp b/src/ui/GpgFrontendUIInit.cpp index 022f0748..fbc6877f 100644 --- a/src/ui/GpgFrontendUIInit.cpp +++ b/src/ui/GpgFrontendUIInit.cpp @@ -103,8 +103,9 @@ void InitGpgFrontendUI(QApplication* app) { // show the loading window waiting_dialog->setModal(true); - waiting_dialog->show(); waiting_dialog->setFocus(); + waiting_dialog->show(); + // new local event looper QEventLoop looper; |