user32: Move freeing of a 16-bit module's classes to wnd16.c.

This commit is contained in:
Alexandre Julliard 2009-12-22 12:33:26 +01:00
parent e3bcc11beb
commit 0fbe20a254
4 changed files with 59 additions and 39 deletions

View File

@ -254,38 +254,6 @@ static void CLASS_FreeClass( CLASS *classPtr )
}
/***********************************************************************
* CLASS_FreeModuleClasses
*/
void CLASS_FreeModuleClasses( HMODULE16 hModule )
{
struct list *ptr, *next;
TRACE("0x%08x\n", hModule);
USER_Lock();
for (ptr = list_head( &class_list ); ptr; ptr = next)
{
CLASS *class = LIST_ENTRY( ptr, CLASS, entry );
next = list_next( &class_list, ptr );
if (class->hInstance == HINSTANCE_32(hModule))
{
BOOL ret;
SERVER_START_REQ( destroy_class )
{
req->atom = class->atomName;
req->instance = wine_server_client_ptr( class->hInstance );
ret = !wine_server_call_err( req );
}
SERVER_END_REQ;
if (ret) CLASS_FreeClass( class );
}
}
USER_Unlock();
}
/***********************************************************************
* CLASS_FindClass
*

View File

@ -126,6 +126,7 @@ extern LRESULT StaticWndProc_common(HWND,UINT,WPARAM,LPARAM,BOOL) DECLSPEC_HIDDE
/* 16-bit support */
extern HWND create_window16(CREATESTRUCTW*,LPCWSTR,HINSTANCE,UINT) DECLSPEC_HIDDEN;
extern void free_module_classes(HINSTANCE16) DECLSPEC_HIDDEN;
extern void register_wow_handlers(void) DECLSPEC_HIDDEN;
extern void WINAPI UserRegisterWowHandlers( const struct wow_handlers16 *new,
struct wow_handlers32 *orig );
@ -138,7 +139,6 @@ extern void CLASS_RegisterBuiltinClasses(void) DECLSPEC_HIDDEN;
extern WNDPROC get_class_winproc( struct tagCLASS *class ) DECLSPEC_HIDDEN;
extern struct dce *get_class_dce( struct tagCLASS *class ) DECLSPEC_HIDDEN;
extern struct dce *set_class_dce( struct tagCLASS *class, struct dce *dce ) DECLSPEC_HIDDEN;
extern void CLASS_FreeModuleClasses( HMODULE16 hModule ) DECLSPEC_HIDDEN;
/* defwnd proc */
extern HBRUSH DEFWND_ControlColor( HDC hDC, UINT ctlType ) DECLSPEC_HIDDEN;

View File

@ -1527,9 +1527,10 @@ void WINAPI SignalProc16( HANDLE16 hModule, UINT16 code,
{
if (code == USIG16_DLL_UNLOAD)
{
hModule = GetExePtr(hModule);
/* HOOK_FreeModuleHooks( hModule ); */
CLASS_FreeModuleClasses( hModule );
free_module_icons( GetExePtr(hModule) );
free_module_classes( hModule );
free_module_icons( hModule );
}
}

View File

@ -23,6 +23,7 @@
#include "win.h"
#include "controls.h"
#include "user_private.h"
#include "wine/list.h"
#include "wine/server.h"
/* size of buffer needed to store an atom string */
@ -34,6 +35,15 @@
static HWND16 hwndSysModal;
struct class_entry
{
struct list entry;
ATOM atom;
HINSTANCE16 inst;
};
static struct list class_list = LIST_INIT( class_list );
struct wnd_enum_info
{
WNDENUMPROC16 proc;
@ -62,6 +72,19 @@ static inline HWND full_insert_after_hwnd( HWND16 hwnd )
return ret;
}
void free_module_classes( HINSTANCE16 inst )
{
struct class_entry *class, *next;
LIST_FOR_EACH_ENTRY_SAFE( class, next, &class_list, struct class_entry, entry )
{
if (class->inst != inst) continue;
list_remove( &class->entry );
UnregisterClassA( (LPCSTR)MAKEINTATOM(class->atom), HINSTANCE_32(class->inst) );
HeapFree( GetProcessHeap(), 0, class );
}
}
/**************************************************************************
* MessageBox (USER.1)
*/
@ -1532,22 +1555,34 @@ BOOL16 WINAPI SetWindowPlacement16( HWND16 hwnd, const WINDOWPLACEMENT16 *wp16 )
*/
ATOM WINAPI RegisterClassEx16( const WNDCLASSEX16 *wc )
{
struct class_entry *class;
WNDCLASSEXA wc32;
HINSTANCE16 inst;
ATOM atom;
inst = GetExePtr( wc->hInstance );
if (!inst) inst = GetModuleHandle16( NULL );
wc32.cbSize = sizeof(wc32);
wc32.style = wc->style;
wc32.lpfnWndProc = WINPROC_AllocProc16( wc->lpfnWndProc );
wc32.cbClsExtra = wc->cbClsExtra;
wc32.cbWndExtra = wc->cbWndExtra;
wc32.hInstance = HINSTANCE_32(GetExePtr(wc->hInstance));
if (!wc32.hInstance) wc32.hInstance = HINSTANCE_32(GetModuleHandle16(NULL));
wc32.hInstance = HINSTANCE_32(inst);
wc32.hIcon = HICON_32(wc->hIcon);
wc32.hCursor = HCURSOR_32(wc->hCursor);
wc32.hbrBackground = HBRUSH_32(wc->hbrBackground);
wc32.lpszMenuName = MapSL(wc->lpszMenuName);
wc32.lpszClassName = MapSL(wc->lpszClassName);
wc32.hIconSm = HICON_32(wc->hIconSm);
return RegisterClassExA( &wc32 );
atom = RegisterClassExA( &wc32 );
if ((class = HeapAlloc( GetProcessHeap(), 0, sizeof(*class) )))
{
class->atom = atom;
class->inst = inst;
list_add_tail( &class_list, &class->entry );
}
return atom;
}
@ -1617,8 +1652,24 @@ INT16 WINAPI GetPriorityClipboardFormat16( UINT16 *list, INT16 count )
*/
BOOL16 WINAPI UnregisterClass16( LPCSTR className, HINSTANCE16 hInstance )
{
ATOM atom;
if (hInstance == GetModuleHandle16("user")) hInstance = 0;
return UnregisterClassA( className, HINSTANCE_32(GetExePtr( hInstance )) );
else hInstance = GetExePtr( hInstance );
if ((atom = GlobalFindAtomA( className )))
{
struct class_entry *class;
LIST_FOR_EACH_ENTRY( class, &class_list, struct class_entry, entry )
{
if (class->inst != hInstance) continue;
if (class->atom != atom) continue;
list_remove( &class->entry );
HeapFree( GetProcessHeap(), 0, class );
break;
}
}
return UnregisterClassA( className, HINSTANCE_32(hInstance) );
}