Ticket #2753: wsdl-clean-shutdown-wip.diff

File wsdl-clean-shutdown-wip.diff, 2.0 KB (added by historic_bruno, 10 years ago)
  • source/lib/sysdep/os/win/wsdl.cpp

     source/lib/sysdep/os/win/wsdl.cpp | 12 ++++++++++--
     1 file changed, 10 insertions(+), 2 deletions(-)
    
    diff --git a/source/lib/sysdep/os/win/wsdl.cpp b/source/lib/sysdep/os/win/wsdl.cpp
    index e2cb3fa..26c8567 100644
    a b static HWND g_hWnd = (HWND)INVALID_HANDLE_VALUE;  
    7070// mostly safe via CS_OWNDC.
    7171static HDC g_hDC = (HDC)INVALID_HANDLE_VALUE;
    7272
     73static ATOM g_ClassAtom = INVALID_ATOM;
    7374
    7475//----------------------------------------------------------------------------
    7576// gamma
    static HWND wnd_CreateWindow(int w, int h)  
    246247    wc.lpfnWndProc = OnMessage;
    247248    wc.lpszClassName = L"WSDL{55752F43-0241-492C-8648-C7243397FCE4}";
    248249    wc.hInstance = hInst;
    249     ATOM class_atom = RegisterClassW(&wc);
     250    g_ClassAtom = RegisterClassW(&wc);
    250251    // ignore failure, which is probably caused by not unregistering the class
    251252    // (does not happen automatically when called from a DLL). just re-use
    252253    // the existing class, which is safe because our class name is unique.
    static HWND wnd_CreateWindow(int w, int h)  
    255256    wnd_UpdateWindowDimensions(windowStyle, w, h);
    256257
    257258    // note: you can override the hard-coded window name via SDL_WM_SetCaption.
    258     HWND hWnd = CreateWindowExW(WS_EX_APPWINDOW, (LPCWSTR)(uintptr_t)class_atom, L"wsdl", windowStyle, 0, 0, w, h, 0, 0, hInst, 0);
     259    HWND hWnd = CreateWindowExW(WS_EX_APPWINDOW, (LPCWSTR)(uintptr_t)g_ClassAtom, L"wsdl", windowStyle, 0, 0, w, h, 0, 0, hInst, 0);
    259260    if(!wutil_IsValidHandle(hWnd))
    260261        DEBUG_WARN_ERR(ERR::FAIL);
    261262    return hWnd;
    static ModuleInitState initState;  
    14951496
    14961497static Status Init()
    14971498{
     1499    is_quitting = false;
    14981500    key_Init();
    14991501    return INFO::OK;
    15001502}
    static void Shutdown()  
    15101512        WARN_IF_FALSE(DestroyWindow(g_hWnd));
    15111513
    15121514    video_Shutdown();
     1515
     1516    if (g_ClassAtom != INVALID_ATOM)
     1517    {
     1518        UnregisterClassW((LPCWSTR)(uintptr_t)g_ClassAtom, GetModuleHandle(0));
     1519        g_ClassAtom = INVALID_ATOM;
     1520    }
    15131521}
    15141522
    15151523int SDL_Init(Uint32 UNUSED(flags))