diff options
| author | Tor Arne Vestbø <tor.arne.vestbo@qt.io> | 2023-10-10 18:27:44 +0200 |
|---|---|---|
| committer | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2023-10-18 18:37:51 +0000 |
| commit | 306551b84afd3d6433b4d80a2f7a5cf8af1cf66f (patch) | |
| tree | 86a2231e34e30f0474ffc7ce0a1c3d2257459e47 /src | |
| parent | 6ccee0304d0bf09f845c5115c82a6ef67f58008d (diff) | |
QQuickWindowImpl: Use direct connection for {visible,visibility}Changed
The connections were made queued because QWindow would emit them also
during destruction, at which point the QQuickWindowImpl was already
destructed, but we can work around this by calling destroy() explicitly
in our destructor. This allows us to use direct connections again,
which are preferable since all we're doing is forwarding the QWindow
state, and results in visibility signals being emitted properly during
destruction of QQuickWindowImpl.
Task-number: QTBUG-98734
Change-Id: I262d8cfccfce005232c62d69e381df09835a33fc
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Diffstat (limited to 'src')
| -rw-r--r-- | src/quick/items/qquickwindowmodule.cpp | 17 | ||||
| -rw-r--r-- | src/quick/items/qquickwindowmodule_p.h | 1 |
2 files changed, 10 insertions, 8 deletions
diff --git a/src/quick/items/qquickwindowmodule.cpp b/src/quick/items/qquickwindowmodule.cpp index d4d7ebc879..47309768ae 100644 --- a/src/quick/items/qquickwindowmodule.cpp +++ b/src/quick/items/qquickwindowmodule.cpp @@ -95,17 +95,18 @@ void QQuickWindowQmlImpl::componentComplete() QQuickWindowQmlImpl::QQuickWindowQmlImpl(QQuickWindowQmlImplPrivate &dd, QWindow *parent) : QQuickWindow(dd, parent) { - // These two signals are called during QWindow's dtor, thus they have to be queued connections - // or else our slots will be called instantly when our destructor has already run but our - // connections haven't been removed yet. - connect(this, &QWindow::visibleChanged, this, &QQuickWindowQmlImpl::visibleChanged, - Qt::QueuedConnection); - connect(this, &QWindow::visibilityChanged, this, &QQuickWindowQmlImpl::visibilityChanged, - Qt::QueuedConnection); - + connect(this, &QWindow::visibleChanged, this, &QQuickWindowQmlImpl::visibleChanged); + connect(this, &QWindow::visibilityChanged, this, &QQuickWindowQmlImpl::visibilityChanged); connect(this, &QWindow::screenChanged, this, &QQuickWindowQmlImpl::screenChanged); } +QQuickWindowQmlImpl::~QQuickWindowQmlImpl() +{ + // Destroy the window while we are still alive, so that any signals + // emitted by the destruction can be delivered properly. + destroy(); +} + bool QQuickWindowQmlImpl::event(QEvent *event) { Q_D(QQuickWindowQmlImpl); diff --git a/src/quick/items/qquickwindowmodule_p.h b/src/quick/items/qquickwindowmodule_p.h index ccf8ef9b91..2112665556 100644 --- a/src/quick/items/qquickwindowmodule_p.h +++ b/src/quick/items/qquickwindowmodule_p.h @@ -47,6 +47,7 @@ class Q_QUICK_PRIVATE_EXPORT QQuickWindowQmlImpl : public QQuickWindow, public Q public: QQuickWindowQmlImpl(QWindow *parent = nullptr); + ~QQuickWindowQmlImpl(); void setVisible(bool visible); void setVisibility(QWindow::Visibility visibility); |
