Module: wine Branch: master Commit: 7370a565436b404570b1b1c4ad58a320368fbd7a URL: http://source.winehq.org/git/wine.git/?a=commit;h=7370a565436b404570b1b1c4ad...
Author: Alexandre Julliard julliard@winehq.org Date: Thu Nov 1 20:34:07 2007 +0100
user32: Delay registration of the builtin classes until the first window is created.
---
dlls/user32/class.c | 25 +++++++++++++++++++++++-- dlls/user32/user_main.c | 3 --- dlls/user32/win.c | 3 +++ 3 files changed, 26 insertions(+), 5 deletions(-)
diff --git a/dlls/user32/class.c b/dlls/user32/class.c index a66f0db..333cb76 100644 --- a/dlls/user32/class.c +++ b/dlls/user32/class.c @@ -64,6 +64,7 @@ typedef struct tagCLASS } CLASS;
static struct list class_list = LIST_INIT( class_list ); +static INIT_ONCE init_once = INIT_ONCE_STATIC_INIT;
#define CLASS_OTHER_PROCESS ((CLASS *)1)
@@ -376,9 +377,9 @@ static void register_builtin( const struct builtin_class_descr *descr )
/*********************************************************************** - * CLASS_RegisterBuiltinClasses + * register_builtins */ -void CLASS_RegisterBuiltinClasses(void) +static BOOL WINAPI register_builtins( INIT_ONCE *once, void *param, void **context ) { register_builtin( &DESKTOP_builtin_class ); register_builtin( &BUTTON_builtin_class ); @@ -393,6 +394,16 @@ void CLASS_RegisterBuiltinClasses(void) register_builtin( &MESSAGE_builtin_class ); register_builtin( &SCROLL_builtin_class ); register_builtin( &STATIC_builtin_class ); + return TRUE; +} + + +/*********************************************************************** + * CLASS_RegisterBuiltinClasses + */ +void CLASS_RegisterBuiltinClasses(void) +{ + InitOnceExecuteOnce( &init_once, register_builtins, NULL, NULL ); }
@@ -488,6 +499,8 @@ ATOM WINAPI RegisterClassExA( const WNDCLASSEXA* wc ) CLASS *classPtr; HINSTANCE instance;
+ InitOnceExecuteOnce( &init_once, register_builtins, NULL, NULL ); + if (wc->cbSize != sizeof(*wc) || wc->cbClsExtra < 0 || wc->cbWndExtra < 0 || wc->hInstance == user32_module) /* we can't register a class for user32 */ { @@ -541,6 +554,8 @@ ATOM WINAPI RegisterClassExW( const WNDCLASSEXW* wc ) CLASS *classPtr; HINSTANCE instance;
+ InitOnceExecuteOnce( &init_once, register_builtins, NULL, NULL ); + if (wc->cbSize != sizeof(*wc) || wc->cbClsExtra < 0 || wc->cbWndExtra < 0 || wc->hInstance == user32_module) /* we can't register a class for user32 */ { @@ -597,6 +612,8 @@ BOOL WINAPI UnregisterClassW( LPCWSTR className, HINSTANCE hInstance ) { CLASS *classPtr = NULL;
+ InitOnceExecuteOnce( &init_once, register_builtins, NULL, NULL ); + SERVER_START_REQ( destroy_class ) { req->instance = wine_server_client_ptr( hInstance ); @@ -1097,6 +1114,8 @@ BOOL WINAPI GetClassInfoExA( HINSTANCE hInstance, LPCSTR name, WNDCLASSEXA *wc )
TRACE("%p %s %p\n", hInstance, debugstr_a(name), wc);
+ InitOnceExecuteOnce( &init_once, register_builtins, NULL, NULL ); + if (!wc) { SetLastError( ERROR_NOACCESS ); @@ -1148,6 +1167,8 @@ BOOL WINAPI GetClassInfoExW( HINSTANCE hInstance, LPCWSTR name, WNDCLASSEXW *wc
TRACE("%p %s %p\n", hInstance, debugstr_w(name), wc);
+ InitOnceExecuteOnce( &init_once, register_builtins, NULL, NULL ); + if (!wc) { SetLastError( ERROR_NOACCESS ); diff --git a/dlls/user32/user_main.c b/dlls/user32/user_main.c index c5b4714..e74ac19 100644 --- a/dlls/user32/user_main.c +++ b/dlls/user32/user_main.c @@ -278,9 +278,6 @@ static BOOL process_attach(void) /* Setup palette function pointers */ palette_init();
- /* Initialize built-in window classes */ - CLASS_RegisterBuiltinClasses(); - return TRUE; }
diff --git a/dlls/user32/win.c b/dlls/user32/win.c index 1b4d34b..d506fee 100644 --- a/dlls/user32/win.c +++ b/dlls/user32/win.c @@ -1391,6 +1391,8 @@ HWND WIN_CreateWindowEx( CREATESTRUCTW *cs, LPCWSTR className, HINSTANCE module, } }
+ CLASS_RegisterBuiltinClasses(); + /* Find the parent window */
parent = cs->hwndParent; @@ -1424,6 +1426,7 @@ HWND WIN_CreateWindowEx( CREATESTRUCTW *cs, LPCWSTR className, HINSTANCE module, SetLastError(ERROR_TLW_WITH_WSCHILD); return 0; /* WS_CHILD needs a parent, but WS_POPUP doesn't */ } + /* are we creating the desktop or HWND_MESSAGE parent itself? */ if (className != (LPCWSTR)DESKTOP_CLASS_ATOM && (IS_INTRESOURCE(className) || strcmpiW( className, messageW )))