Browse Source

Platform: fix a handle leak in Windows-specific DPI scaling code.

Rather unlikely to be hit in practice because the default is virtual DPI
scaling and this is just a fallback, but still.
master
Stanislaw Halik 1 month ago committed by Vladimír Vondruš
parent
commit
f239823e9a
  1. 3
      src/Magnum/Platform/Sdl2Application.cpp

3
src/Magnum/Platform/Sdl2Application.cpp

@ -418,6 +418,9 @@ Vector2 Sdl2Application::dpiScalingInternal(const Implementation::Sdl2DpiScaling
#elif defined(CORRADE_TARGET_WINDOWS) && !defined(CORRADE_TARGET_WINDOWS_RT)
HDC hDC = GetWindowDC(nullptr);
Vector2i monitorSize{GetDeviceCaps(hDC, HORZSIZE), GetDeviceCaps(hDC, VERTSIZE)};
/* The handle is apparently allocated anew each time, so we have to release
it back: https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getwindowdc#remarks */
ReleaseDC(nullptr, hDC);
SDL_DisplayMode mode;
CORRADE_INTERNAL_ASSERT(SDL_GetDesktopDisplayMode(0, &mode) == 0);
auto dpi = Vector2{Vector2i{mode.w, mode.h}*25.4f/Vector2{monitorSize}};

Loading…
Cancel
Save