diff options
author | Tor Arne Vestbø <[email protected]> | 2023-11-20 13:57:50 +0100 |
---|---|---|
committer | Tor Arne Vestbø <[email protected]> | 2023-11-20 21:31:47 +0100 |
commit | 87dd49f63894010f145cd244701f94bb8ce69483 (patch) | |
tree | d9f2aae056b9550507316312dddd85207eb65ac4 | |
parent | 68bbbe28b2642e50da9c3ed2b0cb027224062012 (diff) |
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 <[email protected]>
-rw-r--r-- | src/widgets/kernel/qapplication.cpp | 14 | ||||
-rw-r--r-- | src/widgets/kernel/qapplication_p.h | 2 | ||||
-rw-r--r-- | src/widgets/kernel/qwidget.cpp | 2 |
3 files changed, 6 insertions, 12 deletions
diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp index 8911bd1e2ea..163fb7befff 100644 --- a/src/widgets/kernel/qapplication.cpp +++ b/src/widgets/kernel/qapplication.cpp @@ -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) diff --git a/src/widgets/kernel/qapplication_p.h b/src/widgets/kernel/qapplication_p.h index 4be35320d95..555436f4f4a 100644 --- a/src/widgets/kernel/qapplication_p.h +++ b/src/widgets/kernel/qapplication_p.h @@ -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 *); }; diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp index 23340ea5e55..49fd8ccdc06 100644 --- a/src/widgets/kernel/qwidget.cpp +++ b/src/widgets/kernel/qwidget.cpp @@ -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(); |