From d70c379efc1f709936fc4b57ed7f99af0e303cad Mon Sep 17 00:00:00 2001 From: Hirek Date: Fri, 16 Jan 2026 15:11:20 +0100 Subject: [PATCH] Thread closing improvements --- EU07.cpp | 1 + application.cpp | 59 +++++++++++++++++++++++++------------------------ 2 files changed, 31 insertions(+), 29 deletions(-) diff --git a/EU07.cpp b/EU07.cpp index 2ecf53b3..5493359d 100644 --- a/EU07.cpp +++ b/EU07.cpp @@ -68,6 +68,7 @@ LONG WINAPI CrashHandler(EXCEPTION_POINTERS *ExceptionInfo) MINIDUMP_TYPE dumpType = MINIDUMP_TYPE(MiniDumpWithFullMemory | MiniDumpWithHandleData | MiniDumpWithThreadInfo | MiniDumpWithUnloadedModules | MiniDumpWithIndirectlyReferencedMemory | MiniDumpWithFullMemoryInfo | MiniDumpWithTokenInformation); + MessageBoxA(nullptr, "Simulator crash occured :(\n", "Simulator crashed :(", MB_ICONERROR); MiniDumpWriteDump(GetCurrentProcess(), GetCurrentProcessId(), hFile, dumpType, &dumpInfo, nullptr, nullptr); CloseHandle(hFile); diff --git a/application.cpp b/application.cpp index 0bc4feb9..e39f5611 100644 --- a/application.cpp +++ b/application.cpp @@ -592,7 +592,7 @@ int eu07_application::run() GfxRenderer->SwapBuffers(); if (m_modestack.empty()) - return 0; + break; m_modes[m_modestack.top()]->on_event_poll(); @@ -611,20 +611,21 @@ int eu07_application::run() std::this_thread::sleep_for(Global.minframetime - frametime); } } - Global.applicationQuitOrder = true; - auto it = Global.threads.find("LogService"); - if (it != Global.threads.end()) - { - if (it->second.joinable()) - it->second.join(); - } - - it = Global.threads.find("DiscordRPC"); - if (it != Global.threads.end()) - { - if (it->second.joinable()) - it->second.join(); - } + // Handled by application.exit + // Global.applicationQuitOrder = true; + // auto it = Global.threads.find("LogService"); + // if (it != Global.threads.end()) + // { + // if (it->second.joinable()) + // it->second.join(); + // } + // + // it = Global.threads.find("DiscordRPC"); + // if (it != Global.threads.end()) + // { + // if (it->second.joinable()) + // it->second.join(); + // } return 0; } @@ -657,20 +658,6 @@ void eu07_application::release_python_lock() void eu07_application::exit() { Global.applicationQuitOrder = true; - auto it = Global.threads.find("LogService"); - if (it != Global.threads.end()) - { - if (it->second.joinable()) - it->second.join(); - } - - it = Global.threads.find("DiscordRPC"); - if (it != Global.threads.end()) - { - if (it->second.joinable()) - it->second.join(); - } - for (auto &mode : m_modes) mode.reset(); @@ -691,6 +678,20 @@ void eu07_application::exit() if (!Global.exec_on_exit.empty()) system(Global.exec_on_exit.c_str()); + + auto it = Global.threads.find("LogService"); + if (it != Global.threads.end()) + { + if (it->second.joinable()) + it->second.join(); + } + + it = Global.threads.find("DiscordRPC"); + if (it != Global.threads.end()) + { + if (it->second.joinable()) + it->second.join(); + } } void eu07_application::render_ui()