Patch from Martin Lange (mala-sdl at hotmail.com) to unregister SDL's win32
windowclass when shutting down the video subsystem...this allows you to safely unload/reload the SDL shared library on Windows between initializations. Discussion is here: http://www.devolution.com/pipermail/sdl/2005-February/067424.html --HG-- extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%401148
This commit is contained in:
parent
c8157c1d15
commit
7791c73962
4 changed files with 27 additions and 9 deletions
|
@ -69,7 +69,8 @@ extern "C" {
|
||||||
extern DECLSPEC void SDLCALL SDL_SetModuleHandle(void *hInst);
|
extern DECLSPEC void SDLCALL SDL_SetModuleHandle(void *hInst);
|
||||||
/* This can also be called, but is no longer necessary */
|
/* This can also be called, but is no longer necessary */
|
||||||
extern DECLSPEC int SDLCALL SDL_RegisterApp(char *name, Uint32 style, void *hInst);
|
extern DECLSPEC int SDLCALL SDL_RegisterApp(char *name, Uint32 style, void *hInst);
|
||||||
|
/* This can also be called, but is no longer necessary (SDL_Quit calls it) */
|
||||||
|
extern DECLSPEC void SDLCALL SDL_UnregisterApp();
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -562,11 +562,6 @@ void *SDL_GetModuleHandle(void)
|
||||||
if ( SDL_handle ) {
|
if ( SDL_handle ) {
|
||||||
handle = SDL_handle;
|
handle = SDL_handle;
|
||||||
} else {
|
} else {
|
||||||
/* Warning:
|
|
||||||
If SDL is built as a DLL, this will return a handle to
|
|
||||||
the DLL, not the application, and DirectInput may fail
|
|
||||||
to initialize.
|
|
||||||
*/
|
|
||||||
handle = GetModuleHandle(NULL);
|
handle = GetModuleHandle(NULL);
|
||||||
}
|
}
|
||||||
return(handle);
|
return(handle);
|
||||||
|
@ -575,17 +570,18 @@ void *SDL_GetModuleHandle(void)
|
||||||
/* This allows the SDL_WINDOWID hack */
|
/* This allows the SDL_WINDOWID hack */
|
||||||
const char *SDL_windowid = NULL;
|
const char *SDL_windowid = NULL;
|
||||||
|
|
||||||
|
static int app_registered = 0;
|
||||||
|
|
||||||
/* Register the class for this application -- exported for winmain.c */
|
/* Register the class for this application -- exported for winmain.c */
|
||||||
int SDL_RegisterApp(char *name, Uint32 style, void *hInst)
|
int SDL_RegisterApp(char *name, Uint32 style, void *hInst)
|
||||||
{
|
{
|
||||||
static int initialized = 0;
|
|
||||||
WNDCLASS class;
|
WNDCLASS class;
|
||||||
#ifdef WM_MOUSELEAVE
|
#ifdef WM_MOUSELEAVE
|
||||||
HMODULE handle;
|
HMODULE handle;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Only do this once... */
|
/* Only do this once... */
|
||||||
if ( initialized ) {
|
if ( app_registered ) {
|
||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -646,7 +642,26 @@ int SDL_RegisterApp(char *name, Uint32 style, void *hInst)
|
||||||
/* Check for SDL_WINDOWID hack */
|
/* Check for SDL_WINDOWID hack */
|
||||||
SDL_windowid = getenv("SDL_WINDOWID");
|
SDL_windowid = getenv("SDL_WINDOWID");
|
||||||
|
|
||||||
initialized = 1;
|
app_registered = 1;
|
||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Unregisters the windowclass registered in SDL_RegisterApp above.
|
||||||
|
* Called from DIB_VideoQuit and DX5_VideoQuit when
|
||||||
|
* SDL_QuitSubSystem(INIT_VIDEO) is called.
|
||||||
|
*/
|
||||||
|
void SDL_UnRegisterApp()
|
||||||
|
{
|
||||||
|
WNDCLASS class;
|
||||||
|
|
||||||
|
/* SDL_RegisterApp might not have been called before */
|
||||||
|
if (app_registered) {
|
||||||
|
/* Check for any registered windowclasses. */
|
||||||
|
if (GetClassInfo(SDL_Instance, SDL_Appname, &class)) {
|
||||||
|
UnregisterClass(SDL_Appname, SDL_Instance);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
app_registered = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -971,6 +971,7 @@ void DIB_VideoQuit(_THIS)
|
||||||
}
|
}
|
||||||
DIB_QuitGamma(this);
|
DIB_QuitGamma(this);
|
||||||
DIB_DestroyWindow(this);
|
DIB_DestroyWindow(this);
|
||||||
|
SDL_UnregisterApp();
|
||||||
FlushMessageQueue();
|
FlushMessageQueue();
|
||||||
|
|
||||||
SDL_Window = NULL;
|
SDL_Window = NULL;
|
||||||
|
|
|
@ -2387,6 +2387,7 @@ void DX5_VideoQuit(_THIS)
|
||||||
DIB_QuitGamma(this);
|
DIB_QuitGamma(this);
|
||||||
if ( SDL_Window ) {
|
if ( SDL_Window ) {
|
||||||
DX5_DestroyWindow(this);
|
DX5_DestroyWindow(this);
|
||||||
|
SDL_UnregisterApp();
|
||||||
FlushMessageQueue();
|
FlushMessageQueue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue