diff options
| author | Qt Forward Merge Bot <qt_forward_merge_bot@qt-project.org> | 2019-04-18 01:00:17 +0200 |
|---|---|---|
| committer | Ulf Hermann <ulf.hermann@qt.io> | 2019-04-18 08:01:45 +0200 |
| commit | 934f25028a232c9bccdb842f53fa67959cc8dffc (patch) | |
| tree | a78fef6197d63feab3194eb7f4cd2e10934b18ee /src/quickwidgets/qquickwidget.cpp | |
| parent | f8e90c61c5da4ca5e0aec24d42b2962877289ab2 (diff) | |
| parent | 2bdbf216fe7b6cf9d404b80ac405bd3969f5c07f (diff) | |
Merge remote-tracking branch 'origin/5.13' into dev
Conflicts:
src/qml/qml/qqmlimport.cpp
Change-Id: I6add6267297ea50a646d43d212027a168dca8916
Diffstat (limited to 'src/quickwidgets/qquickwidget.cpp')
| -rw-r--r-- | src/quickwidgets/qquickwidget.cpp | 31 |
1 files changed, 18 insertions, 13 deletions
diff --git a/src/quickwidgets/qquickwidget.cpp b/src/quickwidgets/qquickwidget.cpp index a098c94670..f1a0f0c863 100644 --- a/src/quickwidgets/qquickwidget.cpp +++ b/src/quickwidgets/qquickwidget.cpp @@ -76,6 +76,18 @@ QT_BEGIN_NAMESPACE +// override setVisble to prevent accidental offscreen window being created +// by base class. +class QQuickOffcreenWindowPrivate: public QQuickWindowPrivate { +public: + void setVisible(bool visible) override { + Q_Q(QWindow); + // this stays always invisible + visibility = visible ? QWindow::Windowed : QWindow::Hidden; + q->visibilityChanged(visibility); // workaround for QTBUG-49054 + } +}; + class QQuickWidgetRenderControl : public QQuickRenderControl { public: @@ -94,7 +106,7 @@ void QQuickWidgetPrivate::init(QQmlEngine* e) Q_Q(QQuickWidget); renderControl = new QQuickWidgetRenderControl(q); - offscreenWindow = new QQuickWindow(renderControl); + offscreenWindow = new QQuickWindow(*new QQuickOffcreenWindowPrivate(),renderControl); offscreenWindow->setTitle(QString::fromLatin1("Offscreen")); // Do not call create() on offscreenWindow. @@ -1321,12 +1333,9 @@ void QQuickWidget::showEvent(QShowEvent *) triggerUpdate(); } } - QWindowPrivate *offscreenPrivate = QWindowPrivate::get(d->offscreenWindow); - if (!offscreenPrivate->visible) { - offscreenPrivate->visible = true; - emit d->offscreenWindow->visibleChanged(true); - offscreenPrivate->updateVisibility(); - } + + // note offscreenWindow is "QQuickOffScreenWindow" instance + d->offscreenWindow->setVisible(true); if (QQmlInspectorService *service = QQmlDebugConnector::service<QQmlInspectorService>()) service->setParentWindow(d->offscreenWindow, window()->windowHandle()); } @@ -1337,12 +1346,8 @@ void QQuickWidget::hideEvent(QHideEvent *) Q_D(QQuickWidget); if (!d->offscreenWindow->isPersistentSceneGraph()) d->invalidateRenderControl(); - QWindowPrivate *offscreenPrivate = QWindowPrivate::get(d->offscreenWindow); - if (offscreenPrivate->visible) { - offscreenPrivate->visible = false; - emit d->offscreenWindow->visibleChanged(false); - offscreenPrivate->updateVisibility(); - } + // note offscreenWindow is "QQuickOffScreenWindow" instance + d->offscreenWindow->setVisible(false); if (QQmlInspectorService *service = QQmlDebugConnector::service<QQmlInspectorService>()) service->setParentWindow(d->offscreenWindow, d->offscreenWindow); } |
