1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-04-29 02:36:50 +00:00

Merge branch 'isapphung-postfix' into 'master'

Simplify getIsHungAppWindow

See merge request OpenMW/openmw!2136
This commit is contained in:
jvoisin 2022-07-14 20:39:08 +00:00
commit 8da668e220

View file

@ -24,22 +24,15 @@ namespace Crash
// See: https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-ishungappwindow // See: https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-ishungappwindow
static IsHungAppWindowFn getIsHungAppWindow() noexcept static IsHungAppWindowFn getIsHungAppWindow() noexcept
{ {
static IsHungAppWindowFn isHungAppWindow = nullptr;
static bool isHungAppWindowInitialized = false;
if (isHungAppWindowInitialized)
return isHungAppWindow;
auto user32Handle = LoadLibraryA("user32.dll"); auto user32Handle = LoadLibraryA("user32.dll");
if (user32Handle == nullptr) if (user32Handle == nullptr)
return nullptr; return nullptr;
isHungAppWindow = reinterpret_cast<IsHungAppWindowFn>(GetProcAddress(user32Handle, "IsHungAppWindow")); return reinterpret_cast<IsHungAppWindowFn>(GetProcAddress(user32Handle, "IsHungAppWindow"));
isHungAppWindowInitialized = true;
return isHungAppWindow;
} }
static const IsHungAppWindowFn sIsHungAppWindow = getIsHungAppWindow();
CrashMonitor::CrashMonitor(HANDLE shmHandle) CrashMonitor::CrashMonitor(HANDLE shmHandle)
: mShmHandle(shmHandle) : mShmHandle(shmHandle)
{ {
@ -145,8 +138,8 @@ namespace Crash
else else
return false; return false;
} }
if (auto isHungAppWindow = getIsHungAppWindow(); isHungAppWindow != nullptr) if (sIsHungAppWindow != nullptr)
return isHungAppWindow(mAppWindowHandle); return sIsHungAppWindow(mAppWindowHandle);
else else
{ {
BOOL debuggerPresent; BOOL debuggerPresent;