Windows: Destroy display change window before unregistering window class

The QWindowsScreenManager's m_displayChangeObserver window would still
be alive at the time ~QWindowsContext would unregister window classes,
resulting in a warning that was hidden by the default verbosity of
QWindowsContext::verbose. The result was that we would get a warning
when then trying to re-register the already registered window class.

We now do what we do for m_powerNotification and m_powerDummyWindow,
which is to destroy them explicitly before unregistering their class.

Fixes: QTBUG-125058
Pick-to: 6.5
Change-Id: Id3b02237fdd81f734a58a2314a157cad1289a82c
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
(cherry picked from commit 48cc43a1e00e564438227dc0c251c988cee22483)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Tor Arne Vestbø 2024-05-07 17:27:18 +02:00 committed by Qt Cherry-pick Bot
parent f6b4a48498
commit 107f76f29a
3 changed files with 8 additions and 1 deletions

View File

@ -204,6 +204,8 @@ QWindowsContext::~QWindowsContext()
if (d->m_powerDummyWindow)
DestroyWindow(d->m_powerDummyWindow);
d->m_screenManager.destroyWindow();
unregisterWindowClasses();
if (d->m_oleInitializeResult == S_OK || d->m_oleInitializeResult == S_FALSE) {
#ifdef QT_USE_FACTORY_CACHE_REGISTRATION

View File

@ -698,11 +698,15 @@ void QWindowsScreenManager::initialize()
handleScreenChanges();
}
QWindowsScreenManager::~QWindowsScreenManager()
void QWindowsScreenManager::destroyWindow()
{
qCDebug(lcQpaScreen) << "Destroying display change observer" << m_displayChangeObserver;
DestroyWindow(m_displayChangeObserver);
m_displayChangeObserver = nullptr;
}
QWindowsScreenManager::~QWindowsScreenManager() = default;
bool QWindowsScreenManager::isSingleScreen()
{
return QWindowsContext::instance()->screenManager().screens().size() < 2;

View File

@ -105,6 +105,7 @@ public:
QWindowsScreenManager();
void initialize();
void destroyWindow();
~QWindowsScreenManager();
void clearScreens();