From 46bad85dab6b9f0900894d78f3bf4cec729a2daf Mon Sep 17 00:00:00 2001 From: arm64v8a <48624112+arm64v8a@users.noreply.github.com> Date: Sun, 2 Apr 2023 13:49:46 +0900 Subject: [PATCH] fix restart --- main/NekoRay_DataStore.hpp | 1 + main/main.cpp | 10 +++++----- sys/ExternalProcess.cpp | 1 + sys/ExternalProcess.hpp | 2 -- ui/mainwindow.cpp | 4 +++- 5 files changed, 10 insertions(+), 8 deletions(-) diff --git a/main/NekoRay_DataStore.hpp b/main/NekoRay_DataStore.hpp index 0b0da7110..dbad23c87 100644 --- a/main/NekoRay_DataStore.hpp +++ b/main/NekoRay_DataStore.hpp @@ -65,6 +65,7 @@ namespace NekoRay { int resolve_count = 0; // Flags + QStringList argv = {}; bool flag_use_appdata = false; bool flag_many = false; bool flag_tray = false; diff --git a/main/main.cpp b/main/main.cpp index b90c216ca..fe8dc1d55 100644 --- a/main/main.cpp +++ b/main/main.cpp @@ -52,11 +52,11 @@ int main(int argc, char *argv[]) { #endif // Flags - auto args = QApplication::arguments(); - if (args.contains("-many")) NekoRay::dataStore->flag_many = true; - if (args.contains("-appdata")) NekoRay::dataStore->flag_use_appdata = true; - if (args.contains("-tray")) NekoRay::dataStore->flag_tray = true; - if (args.contains("-debug")) NekoRay::dataStore->flag_debug = true; + NekoRay::dataStore->argv = QApplication::arguments(); + if (NekoRay::dataStore->argv.contains("-many")) NekoRay::dataStore->flag_many = true; + if (NekoRay::dataStore->argv.contains("-appdata")) NekoRay::dataStore->flag_use_appdata = true; + if (NekoRay::dataStore->argv.contains("-tray")) NekoRay::dataStore->flag_tray = true; + if (NekoRay::dataStore->argv.contains("-debug")) NekoRay::dataStore->flag_debug = true; #ifdef NKR_CPP_USE_APPDATA NekoRay::dataStore->flag_use_appdata = true; // Example: Package & MacOS #endif diff --git a/sys/ExternalProcess.cpp b/sys/ExternalProcess.cpp index d8a6c7379..852ad316f 100644 --- a/sys/ExternalProcess.cpp +++ b/sys/ExternalProcess.cpp @@ -1,4 +1,5 @@ #include "ExternalProcess.hpp" +#include "main/NekoRay.hpp" #include #include diff --git a/sys/ExternalProcess.hpp b/sys/ExternalProcess.hpp index 426dcd3d7..71870f999 100644 --- a/sys/ExternalProcess.hpp +++ b/sys/ExternalProcess.hpp @@ -1,7 +1,5 @@ #pragma once -#include "main/NekoRay.hpp" - #include namespace NekoRay::sys { diff --git a/ui/mainwindow.cpp b/ui/mainwindow.cpp index f0e7ad796..f9cdd8b5c 100644 --- a/ui/mainwindow.cpp +++ b/ui/mainwindow.cpp @@ -627,7 +627,9 @@ void MainWindow::on_menu_exit_triggered() { QProcess::startDetached("./updater", QStringList{}); } else if (exit_reason == 2) { QDir::setCurrent(QApplication::applicationDirPath()); - QProcess::startDetached(qEnvironmentVariable("NKR_FROM_LAUNCHER") == "1" ? "./launcher" : QApplication::applicationFilePath(), QStringList{}); + auto arguments = NekoRay::dataStore->argv; + if (arguments.length() > 0) arguments.removeFirst(); + QProcess::startDetached(qEnvironmentVariable("NKR_FROM_LAUNCHER") == "1" ? "./launcher" : QApplication::applicationFilePath(), arguments); } tray->hide(); QCoreApplication::quit();