fix memory leak with console
This commit is contained in:
parent
375ce38049
commit
a4a031ad1b
@ -99,6 +99,8 @@ namespace console
|
||||
_RTL_CRITICAL_SECTION critSect;
|
||||
} s_wcd;
|
||||
|
||||
HBRUSH bk_brush;
|
||||
|
||||
HICON icon;
|
||||
HANDLE logo;
|
||||
|
||||
@ -120,7 +122,7 @@ namespace console
|
||||
case WM_CTLCOLORSTATIC:
|
||||
SetBkColor(reinterpret_cast<HDC>(wparam), CONSOLE_BK_COLOR);
|
||||
SetTextColor(reinterpret_cast<HDC>(wparam), CONSOLE_TEXT_COLOR);
|
||||
return reinterpret_cast<INT_PTR>(CreateSolidBrush(CONSOLE_BK_COLOR));
|
||||
return reinterpret_cast<LONG_PTR>(bk_brush);
|
||||
}
|
||||
|
||||
return DefWindowProcA(hwnd, umsg, wparam, lparam);
|
||||
@ -271,7 +273,7 @@ namespace console
|
||||
wndclass.lpfnWndProc = ConWndProc;
|
||||
wndclass.hInstance = hinstance;
|
||||
wndclass.hIcon = icon;
|
||||
wndclass.hbrBackground = CreateSolidBrush(CONSOLE_BK_COLOR);
|
||||
wndclass.hbrBackground = bk_brush;
|
||||
wndclass.hCursor = LoadCursorA(0, IDC_ARROW);
|
||||
wndclass.lpszMenuName = nullptr;
|
||||
wndclass.lpszClassName = class_name;
|
||||
@ -469,6 +471,8 @@ namespace console
|
||||
{
|
||||
if (!console::is_enabled() || native::is_enabled()) return;
|
||||
|
||||
syscon::bk_brush = CreateSolidBrush(CONSOLE_BK_COLOR);
|
||||
|
||||
const utils::nt::library self;
|
||||
syscon::icon = LoadIconA(self.get_handle(), MAKEINTRESOURCEA(ID_ICON));
|
||||
syscon::logo = LoadImageA(self.get_handle(), MAKEINTRESOURCEA(IMAGE_LOGO), 0, 0, 0, LR_COPYFROMRESOURCE);
|
||||
@ -485,6 +489,8 @@ namespace console
|
||||
{
|
||||
if (!console::is_enabled() || native::is_enabled()) return;
|
||||
|
||||
if (syscon::bk_brush) DeleteObject(syscon::bk_brush);
|
||||
|
||||
if (syscon::icon) DestroyIcon(syscon::icon);
|
||||
if (syscon::logo) DeleteObject(syscon::logo);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user