From 49432f689d2d2b03adb4495bd743d4931d2ee704 Mon Sep 17 00:00:00 2001 From: Akash Mozumdar Date: Sun, 1 Mar 2020 23:41:27 -0700 Subject: [PATCH] (hopefully) fix silent crashes --- GUI/host/exception.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/GUI/host/exception.cpp b/GUI/host/exception.cpp index 9215f9d..4bd8787 100644 --- a/GUI/host/exception.cpp +++ b/GUI/host/exception.cpp @@ -22,8 +22,12 @@ namespace __declspec(noreturn) void Terminate() { - MessageBoxW(NULL, lastError.c_str(), L"Textractor ERROR", MB_ICONERROR); - abort(); + CreateThread(nullptr, 0, [](void* lastError) -> DWORD + { + MessageBoxW(NULL, (wchar_t*)lastError, L"Textractor ERROR", MB_ICONERROR); // might fail to display if called in main thread and exception was in main event loop + abort(); + }, lastError.data(), 0, nullptr); + Sleep(MAXDWORD); } LONG WINAPI ExceptionLogger(EXCEPTION_POINTERS* exception)