summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/windows/qwindowscontext.cpp
diff options
context:
space:
mode:
authorTim Blechmann <tim@klingt.org>2018-12-06 15:39:57 +0800
committerTor Arne Vestbø <tor.arne.vestbo@qt.io>2019-06-18 10:40:06 +0000
commitcf052e0737ecf2850b125c1640fe300699303b70 (patch)
treeb4c82f42bf907b63e2594d3e0d1ad806e33369f3 /src/plugins/platforms/windows/qwindowscontext.cpp
parentb568e931490a7751120dfed1f0bc53f2a4b4192a (diff)
Windows: Use UUIDs instead of function pointer to mangle window classes
Instead of using the address of a function pointer, we name-mangle window classes by using an UUID. This fixes a real-world problem with multiple Qt instances where for some reasons the window function appears to be mapped to the same address. Change-Id: Id27e8d7aa17a4db9c14559224395f49d3ecd8d78 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Diffstat (limited to 'src/plugins/platforms/windows/qwindowscontext.cpp')
-rw-r--r--src/plugins/platforms/windows/qwindowscontext.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/plugins/platforms/windows/qwindowscontext.cpp b/src/plugins/platforms/windows/qwindowscontext.cpp
index de533cab08..38b9823d6b 100644
--- a/src/plugins/platforms/windows/qwindowscontext.cpp
+++ b/src/plugins/platforms/windows/qwindowscontext.cpp
@@ -77,6 +77,7 @@
#include <QtCore/qoperatingsystemversion.h>
#include <QtCore/qsysinfo.h>
#include <QtCore/qscopedpointer.h>
+#include <QtCore/quuid.h>
#include <QtCore/private/qsystemlibrary_p.h>
#include <QtEventDispatcherSupport/private/qwindowsguieventdispatcher_p.h>
@@ -544,7 +545,7 @@ QString QWindowsContext::registerWindowClass(QString cname,
// each one has to have window class names with a unique name
// The first instance gets the unmodified name; if the class
// has already been registered by another instance of Qt then
- // add an instance-specific ID, the address of the window proc.
+ // add a UUID.
static int classExists = -1;
const HINSTANCE appInstance = static_cast<HINSTANCE>(GetModuleHandle(nullptr));
@@ -555,7 +556,7 @@ QString QWindowsContext::registerWindowClass(QString cname,
}
if (classExists)
- cname += QString::number(reinterpret_cast<quintptr>(proc));
+ cname += QUuid::createUuid().toString();
if (d->m_registeredWindowClassNames.contains(cname)) // already registered in our list
return cname;