summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMikaƫl Capelle <capelle.mikael@gmail.com>2021-02-13 18:25:39 +0100
committerGitHub <noreply@github.com>2021-02-13 18:25:39 +0100
commitbd93864ed29dfa7a1cd4ec7ed18b70f0170d0cc2 (patch)
treea40a33911362b0f5de412b77b8bf23d245df1565 /src
parentee4c364ccc6c5fbd81b5136e75005d8b9550ca43 (diff)
parent406d6f28c0ee0e6d6187a0d633f3db07fab57841 (diff)
Merge pull request #1409 from isanae/portable-loop
Portable instance loop.
Diffstat (limited to 'src')
-rw-r--r--src/main.cpp9
-rw-r--r--src/moapplication.cpp2
-rw-r--r--src/shared/util.h1
3 files changed, 9 insertions, 3 deletions
diff --git a/src/main.cpp b/src/main.cpp
index 60d99817..84db88cb 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -80,7 +80,8 @@ int run(int argc, char *argv[])
// stuff that's done only once, even if MO restarts in the loop below
app.firstTimeSetup(multiProcess);
- // force the "Select instance" dialog on startup (only for first loop)
+ // force the "Select instance" dialog on startup, only for first loop or when
+ // the current instance cannot be used
bool pick = cl.pick();
// MO runs in a loop because it can be restarted in several ways, such as
@@ -105,13 +106,17 @@ int run(int argc, char *argv[])
const auto r = app.setup(multiProcess, pick);
pick = false;
- if (r == RestartExitCode) {
+ if (r == RestartExitCode || r == ReselectExitCode) {
// resets things when MO is "restarted"
app.resetForRestart();
// don't reprocess command line
cl.clear();
+ if (r == ReselectExitCode) {
+ pick = true;
+ }
+
continue;
} else if (r != 0) {
// something failed, quit
diff --git a/src/moapplication.cpp b/src/moapplication.cpp
index 11053e66..4a6585dd 100644
--- a/src/moapplication.cpp
+++ b/src/moapplication.cpp
@@ -492,7 +492,7 @@ std::optional<int> MOApplication::setupInstanceLoop(
continue;
} else if (setupResult == SetupInstanceResults::SelectAnother) {
InstanceManager::singleton().clearCurrentInstance();
- return RestartExitCode;
+ return ReselectExitCode;
} else {
return 1;
}
diff --git a/src/shared/util.h b/src/shared/util.h
index 1688a931..d8fdb3a3 100644
--- a/src/shared/util.h
+++ b/src/shared/util.h
@@ -74,6 +74,7 @@ enum class Exit
};
const int RestartExitCode = INT_MAX;
+const int ReselectExitCode = INT_MAX - 1;
using ExitFlags = QFlags<Exit>;
Q_DECLARE_OPERATORS_FOR_FLAGS(ExitFlags);