diff --git a/src/Magnum/Platform/Sdl2Application.cpp b/src/Magnum/Platform/Sdl2Application.cpp index 0c146e72b..a997ca45f 100644 --- a/src/Magnum/Platform/Sdl2Application.cpp +++ b/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}};