summaryrefslogtreecommitdiff
path: root/src/main.cpp
diff options
context:
space:
mode:
authorMikaƫl Capelle <capelle.mikael@gmail.com>2023-07-09 17:36:03 +0200
committerGitHub <noreply@github.com>2023-07-09 17:36:03 +0200
commitef94aee28464039672b277243a0181ae93550d6c (patch)
tree0575a68af5f154e9d6d0738edbaefb16a11d6f5c /src/main.cpp
parent7d6cb8528d20e36a4cee822263865ee2f7f32481 (diff)
parent3de050e9c03e553f7ae3f780f6bd080a30ae123e (diff)
Merge pull request #1839 from Holt59/ci/initial-gh-action-for-build
Clang-Format + Github Workflow
Diffstat (limited to 'src/main.cpp')
-rw-r--r--src/main.cpp65
1 files changed, 24 insertions, 41 deletions
diff --git a/src/main.cpp b/src/main.cpp
index 84db88cb..de157859 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -1,36 +1,36 @@
-#include "multiprocess.h"
-#include "loglist.h"
-#include "moapplication.h"
-#include "organizercore.h"
#include "commandline.h"
#include "env.h"
#include "instancemanager.h"
-#include "thread_utils.h"
+#include "loglist.h"
+#include "moapplication.h"
+#include "multiprocess.h"
+#include "organizercore.h"
#include "shared/util.h"
-#include <report.h>
+#include "thread_utils.h"
#include <log.h>
+#include <report.h>
using namespace MOBase;
thread_local LPTOP_LEVEL_EXCEPTION_FILTER g_prevExceptionFilter = nullptr;
-thread_local std::terminate_handler g_prevTerminateHandler = nullptr;
+thread_local std::terminate_handler g_prevTerminateHandler = nullptr;
-int run(int argc, char *argv[]);
+int run(int argc, char* argv[]);
-int main(int argc, char *argv[])
+int main(int argc, char* argv[])
{
const int r = run(argc, argv);
std::cout << "mod organizer done\n";
return r;
}
-int run(int argc, char *argv[])
+int run(int argc, char* argv[])
{
MOShared::SetThisThreadName("main");
setExceptionHandlers();
cl::CommandLine cl;
- if (auto r=cl.process(GetCommandLineW())) {
+ if (auto r = cl.process(GetCommandLineW())) {
return *r;
}
@@ -42,13 +42,11 @@ int run(int argc, char *argv[])
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
MOApplication app(argc, argv);
-
// check if the command line wants to run something right now
- if (auto r=cl.runPostApplication(app)) {
+ if (auto r = cl.runPostApplication(app)) {
return *r;
}
-
// check if there's another process running
MOMultiProcess multiProcess(cl.multiple());
@@ -62,21 +60,19 @@ int run(int argc, char *argv[])
}
QMessageBox::information(
- nullptr, QObject::tr("Mod Organizer"),
- QObject::tr("An instance of Mod Organizer is already running"));
+ nullptr, QObject::tr("Mod Organizer"),
+ QObject::tr("An instance of Mod Organizer is already running"));
return 1;
}
-
// check if the command line wants to run something right now
- if (auto r=cl.runPostMultiProcess(multiProcess)) {
+ if (auto r = cl.runPostMultiProcess(multiProcess)) {
return *r;
}
tt.stop();
-
// stuff that's done only once, even if MO restarts in the loop below
app.firstTimeSetup(multiProcess);
@@ -86,10 +82,8 @@ int run(int argc, char *argv[])
// MO runs in a loop because it can be restarted in several ways, such as
// when switching instances or changing some settings
- for (;;)
- {
- try
- {
+ for (;;) {
+ try {
auto& m = InstanceManager::singleton();
if (cl.instance()) {
@@ -100,11 +94,10 @@ int run(int argc, char *argv[])
m.overrideProfile(*cl.profile());
}
-
// set up plugins, OrganizerCore, etc.
{
const auto r = app.setup(multiProcess, pick);
- pick = false;
+ pick = false;
if (r == RestartExitCode || r == ReselectExitCode) {
// resets things when MO is "restarted"
@@ -124,17 +117,14 @@ int run(int argc, char *argv[])
}
}
-
// check if the command line wants to run something right now
- if (auto r=cl.runPostOrganizer(app.core())) {
+ if (auto r = cl.runPostOrganizer(app.core())) {
return *r;
}
-
// run the main window
const auto r = app.run(multiProcess);
-
if (r == RestartExitCode) {
// resets things when MO is "restarted"
app.resetForRestart();
@@ -146,9 +136,7 @@ int run(int argc, char *argv[])
}
return r;
- }
- catch (const std::exception &e)
- {
+ } catch (const std::exception& e) {
reportError(e.what());
return 1;
}
@@ -178,16 +166,11 @@ LONG WINAPI onUnhandledException(_EXCEPTION_POINTERS* ptrs)
void onTerminate() noexcept
{
- __try
- {
+ __try {
// force an exception to get a valid stack trace for this thread
*(int*)0 = 42;
- }
- __except
- (
- onUnhandledException(GetExceptionInformation()), EXCEPTION_EXECUTE_HANDLER
- )
- {
+ } __except (onUnhandledException(GetExceptionInformation()),
+ EXCEPTION_EXECUTE_HANDLER) {
}
if (g_prevTerminateHandler) {
@@ -204,6 +187,6 @@ void setExceptionHandlers()
return;
}
- g_prevExceptionFilter = SetUnhandledExceptionFilter(onUnhandledException);
+ g_prevExceptionFilter = SetUnhandledExceptionFilter(onUnhandledException);
g_prevTerminateHandler = std::set_terminate(onTerminate);
}