Skip to content

Commit

Permalink
feat: log exit tasks to console (WerWolv#1363)
Browse files Browse the repository at this point in the history
  • Loading branch information
iTrooz authored Oct 11, 2023
1 parent afa149f commit b908965
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 4 deletions.
5 changes: 5 additions & 0 deletions main/gui/include/init/tasks.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ namespace hex::init {
bool async;
};

/**
* @brief Runs the exit tasks and print them to console
*/
void runExitTasks();

std::vector<Task> getInitTasks();
std::vector<Task> getExitTasks();
}
3 changes: 1 addition & 2 deletions main/gui/source/crash_handlers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,7 @@ namespace hex::crash {
EventManager::post<EventAbnormalTermination>(signalNumber);

// Run exit tasks
for (const auto &[name, task, async] : init::getExitTasks())
task();
init::runExitTasks();

// Terminate all asynchronous tasks
TaskManager::exit();
Expand Down
8 changes: 8 additions & 0 deletions main/gui/source/init/tasks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -608,6 +608,14 @@ namespace hex::init {
return true;
}

// run all exit taks, and print to console
void runExitTasks() {
for (const auto &[name, task, async] : init::getExitTasks()) {
task();
log::info("Finished exit task {}", name);
}
}

std::vector<Task> getInitTasks() {
return {
{ "Setting up environment", setupEnvironment, false },
Expand Down
3 changes: 1 addition & 2 deletions main/gui/source/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,7 @@ namespace {
*/
void deinitializeImHex() {
// Run exit tasks
for (const auto &[name, task, async] : init::getExitTasks())
task();
init::runExitTasks();

// Terminate all asynchronous tasks
TaskManager::exit();
Expand Down

0 comments on commit b908965

Please sign in to comment.