Make QApplicationPrivate::active_window private

The active window of QApplication overlaps largely with the focus window
of QGuiApplication. As a first step towards potentially removing the
active_window member, make it private so we control access to it.

Task-number: QTBUG-119287
Change-Id: I95785fea3ba4444db64063f4e4d3d3004465ef64
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
bb10
Tor Arne Vestbø 2023-11-20 13:57:50 +01:00
parent 68bbbe28b2
commit 87dd49f638
3 changed files with 6 additions and 12 deletions

View File

@ -310,7 +310,6 @@ QWidget *QApplication::topLevelAt(const QPoint &pos)
*/
void qt_init_tooltip_palette();
void qt_cleanup();
QStyle *QApplicationPrivate::app_style = nullptr; // default application style
#ifndef QT_NO_STYLE_STYLESHEET
@ -708,7 +707,10 @@ QApplication::~QApplication()
d->cleanupMultitouch();
qt_cleanup();
QPixmapCache::clear();
QColormap::cleanup();
QApplicationPrivate::active_window = nullptr; //### this should not be necessary
if (QApplicationPrivate::widgetCount)
qDebug("Widgets left: %i Max widgets: %i \n", QWidgetPrivate::instanceCounter, QWidgetPrivate::maxInstances);
@ -719,14 +721,6 @@ QApplication::~QApplication()
QApplicationPrivate::widgetCount = false;
}
void qt_cleanup()
{
QPixmapCache::clear();
QColormap::cleanup();
QApplicationPrivate::active_window = nullptr; //### this should not be necessary
}
/*!
\fn QWidget *QApplication::widgetAt(const QPoint &point)

View File

@ -145,7 +145,6 @@ public:
static QWidget *main_widget;
static QWidget *focus_widget;
static QWidget *hidden_focus_widget;
static QWidget *active_window;
#if QT_CONFIG(wheelevent)
static int wheel_scroll_lines;
static QPointer<QWidget> wheel_widget;
@ -228,6 +227,7 @@ private:
static void giveFocusAccordingToFocusPolicy(QWidget *w, QEvent *event, QPoint localPos);
static bool shouldSetFocus(QWidget *w, Qt::FocusPolicy policy);
static QWidget *active_window;
static bool isAlien(QWidget *);
};

View File

@ -12448,7 +12448,7 @@ void QWidget::destroy(bool destroyWindow, bool destroySubWindows)
if ((windowType() == Qt::Popup) && qApp)
qApp->d_func()->closePopup(this);
if (this == QApplicationPrivate::active_window)
if (this == qApp->activeWindow())
QApplicationPrivate::setActiveWindow(nullptr);
if (QWidget::mouseGrabber() == this)
releaseMouse();