refactor: Enable unreachable cleanup logic in main()
> refactor `main_implemntation()` cleanup to run once on `launcher::shutdown()`, not sure why it was defined like that (unreachable code, at least for iidx) > not thread safe, but probably not needed (no obvious failures as well) > related to #1
This commit is contained in:
@@ -2067,9 +2067,8 @@ int main_implementation(int argc, char *argv[]) {
|
|||||||
game->post_attach();
|
game->post_attach();
|
||||||
}
|
}
|
||||||
|
|
||||||
// game start
|
// cleanup procedure
|
||||||
log_info("launcher", "calling game entry");
|
launcher::on_shutdown = [&]() {
|
||||||
avs::game::entry_main();
|
|
||||||
|
|
||||||
// clear presence
|
// clear presence
|
||||||
richpresence::shutdown();
|
richpresence::shutdown();
|
||||||
@@ -2158,6 +2157,11 @@ int main_implementation(int argc, char *argv[]) {
|
|||||||
#ifdef SPICE64
|
#ifdef SPICE64
|
||||||
games::iidx::camera_release();
|
games::iidx::camera_release();
|
||||||
#endif
|
#endif
|
||||||
|
};
|
||||||
|
|
||||||
|
// game start
|
||||||
|
log_info("launcher", "calling game entry");
|
||||||
|
avs::game::entry_main();
|
||||||
|
|
||||||
// shutdown
|
// shutdown
|
||||||
log_warning("launcher", "end");
|
log_warning("launcher", "end");
|
||||||
|
|||||||
@@ -15,11 +15,15 @@
|
|||||||
|
|
||||||
namespace launcher {
|
namespace launcher {
|
||||||
|
|
||||||
|
std::function<void()> on_shutdown = []() {};
|
||||||
|
|
||||||
void stop_subsystems() {
|
void stop_subsystems() {
|
||||||
// note that it is possible for stop_subsystems to be called multiple times
|
// note that it is possible for stop_subsystems to be called multiple times
|
||||||
// (e.g., crashing, and then closing the window)
|
// (e.g., crashing, and then closing the window)
|
||||||
// therefore, subsystems need to be guarded against multiple unload attempts
|
// therefore, subsystems need to be guarded against multiple unload attempts
|
||||||
log_info("launcher", "stopping subsystems");
|
log_info("launcher", "stopping subsystems");
|
||||||
|
on_shutdown(); //_BUG: not thread safe, required?
|
||||||
|
on_shutdown = []() {};
|
||||||
|
|
||||||
// flush/stop logger
|
// flush/stop logger
|
||||||
logger::stop();
|
logger::stop();
|
||||||
|
|||||||
@@ -2,8 +2,10 @@
|
|||||||
|
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <functional>
|
||||||
|
|
||||||
namespace launcher {
|
namespace launcher {
|
||||||
|
extern std::function<void()> on_shutdown;
|
||||||
void stop_subsystems();
|
void stop_subsystems();
|
||||||
void kill(UINT exit_code = EXIT_FAILURE);
|
void kill(UINT exit_code = EXIT_FAILURE);
|
||||||
void shutdown(UINT exit_code = EXIT_SUCCESS);
|
void shutdown(UINT exit_code = EXIT_SUCCESS);
|
||||||
|
|||||||
Reference in New Issue
Block a user