Commit 7370a565 authored by Alexandre Julliard's avatar Alexandre Julliard

user32: Delay registration of the builtin classes until the first window is created.

parent 13149b67
......@@ -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 );
......
......@@ -278,9 +278,6 @@ static BOOL process_attach(void)
/* Setup palette function pointers */
palette_init();
/* Initialize built-in window classes */
CLASS_RegisterBuiltinClasses();
return TRUE;
}
......
......@@ -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 )))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment