From 5411b67e05a550205b6c0438bb1339e17f8a347d Mon Sep 17 00:00:00 2001 From: Ben Vanik Date: Mon, 7 Sep 2015 09:08:38 -0700 Subject: [PATCH] Only register window class once. --- src/xenia/ui/window_win.cc | 36 ++++++++++++++++++++---------------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/src/xenia/ui/window_win.cc b/src/xenia/ui/window_win.cc index 71d011d03..614b1f1fa 100644 --- a/src/xenia/ui/window_win.cc +++ b/src/xenia/ui/window_win.cc @@ -38,22 +38,26 @@ bool Win32Window::Initialize() { return OnCreate(); } bool Win32Window::OnCreate() { HINSTANCE hInstance = GetModuleHandle(nullptr); - WNDCLASSEX wcex; - wcex.cbSize = sizeof(WNDCLASSEX); - wcex.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC; - wcex.lpfnWndProc = Win32Window::WndProcThunk; - wcex.cbClsExtra = 0; - wcex.cbWndExtra = 0; - wcex.hInstance = hInstance; - wcex.hIcon = nullptr; // LoadIcon(hInstance, (LPCTSTR)IDI_TUTORIAL1); - wcex.hIconSm = nullptr; // LoadIcon(hInstance, (LPCTSTR)IDI_TUTORIAL1); - wcex.hCursor = LoadCursor(nullptr, IDC_ARROW); - wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1); - wcex.lpszMenuName = nullptr; - wcex.lpszClassName = L"XeniaWindowClass"; - if (!RegisterClassEx(&wcex)) { - XELOGE("RegisterClassEx failed"); - return false; + static bool has_registered_class = false; + if (!has_registered_class) { + WNDCLASSEX wcex; + wcex.cbSize = sizeof(WNDCLASSEX); + wcex.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC; + wcex.lpfnWndProc = Win32Window::WndProcThunk; + wcex.cbClsExtra = 0; + wcex.cbWndExtra = 0; + wcex.hInstance = hInstance; + wcex.hIcon = nullptr; // LoadIcon(hInstance, (LPCTSTR)IDI_TUTORIAL1); + wcex.hIconSm = nullptr; // LoadIcon(hInstance, (LPCTSTR)IDI_TUTORIAL1); + wcex.hCursor = LoadCursor(nullptr, IDC_ARROW); + wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1); + wcex.lpszMenuName = nullptr; + wcex.lpszClassName = L"XeniaWindowClass"; + if (!RegisterClassEx(&wcex)) { + XELOGE("RegisterClassEx failed"); + return false; + } + has_registered_class = true; } // Setup initial size.