impr: Prevent ImHex from getting stuck in an infinite crash loop

This commit is contained in:
WerWolv 2024-03-02 09:52:09 +01:00
parent e561f49e80
commit 8f3f941600

View file

@ -151,14 +151,30 @@ namespace hex {
}
void Window::fullFrame() {
static u32 crashWatchdog = 0;
try {
this->frameBegin();
this->frame();
this->frameEnd();
// Feed the watchdog
crashWatchdog = 0;
} catch (...) {
// If an exception keeps being thrown, abort the application after 10 frames
// This is done to avoid the application getting stuck in an infinite loop of exceptions
crashWatchdog += 1;
if (crashWatchdog > 10) {
log::fatal("Crash watchdog triggered, aborting");
std::abort();
}
// Try to recover from the exception by bringing ImGui back into a working state
ImGui::ErrorCheckEndFrameRecover(errorRecoverLogCallback, nullptr);
ImGui::EndFrame();
ImGui::UpdatePlatformWindows();
// Handle the exception
handleException();
}
}