summaryrefslogtreecommitdiffstats
path: root/video
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2015-09-22 21:54:43 +0200
committerwm4 <wm4@nowhere>2015-09-22 21:54:43 +0200
commit4d747400bbc9d4b4b3da18a175be3d602a92f320 (patch)
treed7e5b6978bfe8e7d4ce1b315b8f41d75e18ae3f7 /video
parent8838c4a5b18f7079fabdd6dc1b37f3aacc7f20c2 (diff)
downloadmpv-4d747400bbc9d4b4b3da18a175be3d602a92f320.tar.bz2
mpv-4d747400bbc9d4b4b3da18a175be3d602a92f320.tar.xz
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).
Diffstat (limited to 'video')
-rw-r--r--video/out/w32_common.c7
1 files changed, 1 insertions, 6 deletions
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;