1
0
mirror of synced 2024-11-28 09:30:51 +01:00

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() { void Window::fullFrame() {
static u32 crashWatchdog = 0;
try { try {
this->frameBegin(); this->frameBegin();
this->frame(); this->frame();
this->frameEnd(); this->frameEnd();
// Feed the watchdog
crashWatchdog = 0;
} catch (...) { } 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::ErrorCheckEndFrameRecover(errorRecoverLogCallback, nullptr);
ImGui::EndFrame(); ImGui::EndFrame();
ImGui::UpdatePlatformWindows(); ImGui::UpdatePlatformWindows();
// Handle the exception
handleException(); handleException();
} }
} }