From 4857fee0fc6a9b277a779266d521d4dc1ca3bd95 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Thu, 14 May 2020 12:35:46 +0200 Subject: [PATCH] Windows QPA: Fix window class name clash when mixing Qt libraries MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fix the check of the return value of GetClassInfo() to detect a clash when mixing libraries with identical Qt namespaces. Pick-to: 5.15 Fixes: QTBUG-84005 Change-Id: I2d13b909a85dae947c65551b7e390334c83d2e2a Reviewed-by: André de la Rocha Reviewed-by: Oliver Wolff --- src/plugins/platforms/windows/qwindowscontext.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/plugins/platforms/windows/qwindowscontext.cpp b/src/plugins/platforms/windows/qwindowscontext.cpp index 20a9e2da941..5765b5aa6c2 100644 --- a/src/plugins/platforms/windows/qwindowscontext.cpp +++ b/src/plugins/platforms/windows/qwindowscontext.cpp @@ -643,9 +643,10 @@ QString QWindowsContext::registerWindowClass(QString cname, // has already been registered by another instance of Qt then // add a UUID. The check needs to be performed for each name // in case new message windows are added (QTBUG-81347). + // Note: GetClassInfo() returns != 0 when a class exists. const auto appInstance = static_cast(GetModuleHandle(nullptr)); WNDCLASS wcinfo; - const bool classExists = GetClassInfo(appInstance, reinterpret_cast(cname.utf16()), &wcinfo) == TRUE + const bool classExists = GetClassInfo(appInstance, reinterpret_cast(cname.utf16()), &wcinfo) != FALSE && wcinfo.lpfnWndProc != proc; if (classExists)