From 327a83a54bb71ca22052a374a1e179ef3061ec26 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 19 Apr 2019 07:33:51 +0200 Subject: [PATCH] - fixed: GetDisplayDeviceName must always pick a valid monitor. There is no default here, so if vid_adapter is invalid for whatever reason the engine would crash without a defined setting. --- src/win32/win32basevideo.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/win32/win32basevideo.cpp b/src/win32/win32basevideo.cpp index 2d8ee7a2f..cc37848f1 100644 --- a/src/win32/win32basevideo.cpp +++ b/src/win32/win32basevideo.cpp @@ -90,7 +90,7 @@ static BOOL CALLBACK GetDisplayDeviceNameMonitorEnumProc(HMONITOR hMonitor, HDC, // This assumes the monitors are returned by EnumDisplayMonitors in the // order they're found in the Direct3D9 adapters list. Fingers crossed... - if (state->curIdx == vid_adapter) + if (state->curIdx == vid_adapter || state->hFoundMonitor == nullptr) { state->hFoundMonitor = hMonitor; @@ -119,7 +119,7 @@ void Win32BaseVideo::GetDisplayDeviceName() MonitorEnumState mes; mes.curIdx = 1; - mes.hFoundMonitor = 0; + mes.hFoundMonitor = nullptr; // Could also use EnumDisplayDevices, I guess. That might work. if (EnumDisplayMonitors(0, 0, &GetDisplayDeviceNameMonitorEnumProc, LPARAM(&mes)))