From 4d747400bbc9d4b4b3da18a175be3d602a92f320 Mon Sep 17 00:00:00 2001 From: wm4 Date: Tue, 22 Sep 2015 21:54:43 +0200 Subject: win32: allow multiple windows at the same time Window classes are process-wide (or at least DLL-wide), so you can't have 2 classes with the same name. Our code attempted to do this when for example 2 libmpv instances were created within the same process. This failed, because RegisterWindowEx() fails if the class already exists. Fix this by ignoring RegisterWindowEx() errors. If the class can really not be registered, we will fail on CreateWindowEx() instead. Of course we also can't unregister the class, as another thread might be using it. Windows will free the class automatically if the DLL is unloaded or the process terminates. Fixes #2319 (hopefully). --- video/out/w32_common.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) (limited to 'video') diff --git a/video/out/w32_common.c b/video/out/w32_common.c index c327403dab..905fb42141 100644 --- a/video/out/w32_common.c +++ b/video/out/w32_common.c @@ -1136,11 +1136,7 @@ static void *gui_thread(void *ptr) .hCursor = LoadCursor(NULL, IDC_ARROW), .lpszClassName = classname, }; - - if (!RegisterClassExW(&wcex)) { - MP_ERR(w32, "unable to register window class!\n"); - goto done; - } + RegisterClassExW(&wcex); w32_thread_context = w32; @@ -1227,7 +1223,6 @@ done: if (ole_ok) OleUninitialize(); SetThreadExecutionState(ES_CONTINUOUS); - UnregisterClassW(classname, 0); w32_thread_context = NULL; return NULL; -- cgit v1.2.3