summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/plugins/platforms/windows/qwindowswindowclassregistry.cpp24
-rw-r--r--src/plugins/platforms/windows/qwindowswindowclassregistry.h2
2 files changed, 20 insertions, 6 deletions
diff --git a/src/plugins/platforms/windows/qwindowswindowclassregistry.cpp b/src/plugins/platforms/windows/qwindowswindowclassregistry.cpp
index 5b564abae5d..8bf2fb887f1 100644
--- a/src/plugins/platforms/windows/qwindowswindowclassregistry.cpp
+++ b/src/plugins/platforms/windows/qwindowswindowclassregistry.cpp
@@ -69,17 +69,14 @@ QString QWindowsWindowClassRegistry::registerWindowClass(const QWindowsWindowCla
// 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<HINSTANCE>(GetModuleHandle(nullptr));
- WNDCLASS wcinfo;
- const bool classExists = GetClassInfo(appInstance, reinterpret_cast<LPCWSTR>(className.utf16()), &wcinfo) != FALSE
- && wcinfo.lpfnWndProc != description.procedure;
-
- if (classExists)
+ if (shouldDecorateWindowClassName(description))
className += QUuid::createUuid().toString();
if (m_registeredWindowClassNames.contains(className)) // already registered in our list
return className;
+ const auto appInstance = static_cast<HINSTANCE>(GetModuleHandle(nullptr));
+
WNDCLASSEX wc{};
wc.cbSize = sizeof(WNDCLASSEX);
wc.style = description.style;
@@ -121,6 +118,21 @@ QString QWindowsWindowClassRegistry::registerWindowClass(QString name, WNDPROC p
return registerWindowClass(QWindowsWindowClassDescription::fromName(name, procedure));
}
+bool QWindowsWindowClassRegistry::shouldDecorateWindowClassName(const QWindowsWindowClassDescription &description) const
+{
+ return shouldDecorateWindowClassName(description.name, description.procedure);
+}
+
+bool QWindowsWindowClassRegistry::shouldDecorateWindowClassName(const QString &name, WNDPROC procedure) const
+{
+ const auto appInstance = static_cast<HINSTANCE>(GetModuleHandle(nullptr));
+
+ WNDCLASS wc{};
+
+ return GetClassInfo(appInstance, reinterpret_cast<LPCWSTR>(name.utf16()), &wc) != FALSE
+ && wc.lpfnWndProc != procedure;
+}
+
void QWindowsWindowClassRegistry::unregisterWindowClasses()
{
const auto appInstance = static_cast<HINSTANCE>(GetModuleHandle(nullptr));
diff --git a/src/plugins/platforms/windows/qwindowswindowclassregistry.h b/src/plugins/platforms/windows/qwindowswindowclassregistry.h
index 44f274de2b2..c4a36b7f3c4 100644
--- a/src/plugins/platforms/windows/qwindowswindowclassregistry.h
+++ b/src/plugins/platforms/windows/qwindowswindowclassregistry.h
@@ -34,6 +34,8 @@ public:
private:
static QString classNamePrefix();
+ bool shouldDecorateWindowClassName(const QWindowsWindowClassDescription &description) const;
+ bool shouldDecorateWindowClassName(const QString &name, WNDPROC procedure) const;
void unregisterWindowClasses();
static QWindowsWindowClassRegistry *m_instance;