mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-09-27 19:01:02 +00: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:
co-authored by
Fernando Marino
Claude Sonnet 5
parent
ae27a795b6
commit
d976d9eb0c
@@ -990,6 +990,7 @@ EmbossStyles Emboss::get_font_list_by_enumeration() {
|
||||
std::vector<std::wstring> font_names;
|
||||
EnumFontFamilies(hDC, (LPCTSTR) NULL, EnumFamCallBack,
|
||||
(LPARAM) &font_names);
|
||||
ReleaseDC(NULL, hDC);
|
||||
|
||||
EmbossStyles font_list;
|
||||
for (const std::wstring &font_name : font_names) {
|
||||
|
||||
@@ -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