mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-11-30 08:55:26 -05:00
Release the DC after GetDC in get_dpi_for_window and font enumeration (#15919)
get_dpi_for_window's pre-8.1 fallback and get_font_list_by_enumeration both called GetDC without a matching ReleaseDC, leaking a GDI handle each call. get_dpi_for_window runs on every mouse-move over the 3D viewport, so the leak exhausts the per-process GDI handle limit and hangs the app within minutes on Windows 7/8. Co-authored-by: Fernando Marino <f.marino@rheagroup.com> Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
2 files changed
+4
-1
No files matched your search
@@ -247,7 +247,9 @@ int get_dpi_for_window(const wxWindow *window)
|
||||
|
||||
const HDC hdc = GetDC(hwnd);
|
||||
if (hdc == NULL) { return DPI_DEFAULT; }
|
||||
return GetDeviceCaps(hdc, LOGPIXELSX);
|
||||
const int dpi = GetDeviceCaps(hdc, LOGPIXELSX);
|
||||
ReleaseDC(hwnd, hdc); // GetDC's handle must be released, unlike GetWindowDC's
|
||||
return dpi;
|
||||
}
|
||||
#elif defined __linux__
|
||||
// TODO
|
||||
|
||||
Reference in new issue
Block a user