diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/quick/items/qquickrendercontrol.cpp | 17 | ||||
-rw-r--r-- | src/quick/items/qquickrendercontrol_p.h | 1 | ||||
-rw-r--r-- | src/quickwidgets/qquickwidget.cpp | 12 | ||||
-rw-r--r-- | src/quickwidgets/qquickwidget_p.h | 2 |
4 files changed, 13 insertions, 19 deletions
diff --git a/src/quick/items/qquickrendercontrol.cpp b/src/quick/items/qquickrendercontrol.cpp index 2842d7e933..e28669ceb3 100644 --- a/src/quick/items/qquickrendercontrol.cpp +++ b/src/quick/items/qquickrendercontrol.cpp @@ -123,12 +123,6 @@ void QQuickRenderControl::initialize(QOpenGLContext *gl) d->rc->initialize(gl); } -void QQuickRenderControl::invalidate() -{ - Q_D(QQuickRenderControl); - d->rc->invalidate(); -} - /*! This function should be called as late as possible before sync(). In a threaded scenario, rendering can happen in parallel with this function. @@ -165,7 +159,7 @@ bool QQuickRenderControl::sync() Stop rendering and release resources. This function is typically called when the window is hidden. Requires a current context. */ -void QQuickRenderControl::stop() +void QQuickRenderControl::invalidate() { Q_D(QQuickRenderControl); if (!d->window) @@ -175,10 +169,11 @@ void QQuickRenderControl::stop() cd->fireAboutToStop(); cd->cleanupNodesOnShutdown(); - if (!cd->persistentSceneGraph) { - d->rc->invalidate(); - QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); - } + // We must invalidate since the context can potentially be destroyed by the + // application right after returning from this function. Invalidating is + // also essential to allow a subsequent initialize() to succeed. + d->rc->invalidate(); + QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); } /*! diff --git a/src/quick/items/qquickrendercontrol_p.h b/src/quick/items/qquickrendercontrol_p.h index cc30e37724..d8d5b09a9c 100644 --- a/src/quick/items/qquickrendercontrol_p.h +++ b/src/quick/items/qquickrendercontrol_p.h @@ -74,7 +74,6 @@ public: void polishItems(); void render(); bool sync(); - void stop(); QImage grab(); diff --git a/src/quickwidgets/qquickwidget.cpp b/src/quickwidgets/qquickwidget.cpp index 77d16222d2..8a61e371e7 100644 --- a/src/quickwidgets/qquickwidget.cpp +++ b/src/quickwidgets/qquickwidget.cpp @@ -116,23 +116,23 @@ void QQuickWidgetPrivate::init(QQmlEngine* e) QObject::connect(renderControl, SIGNAL(sceneChanged()), q, SLOT(triggerUpdate())); } -void QQuickWidgetPrivate::stopRenderControl() +void QQuickWidgetPrivate::invalidateRenderControl() { if (!context) // this is not an error, could be called before creating the context, or multiple times return; bool success = context->makeCurrent(offscreenSurface); if (!success) { - qWarning("QQuickWidget::stopRenderControl could not make context current"); + qWarning("QQuickWidget::invalidateRenderControl could not make context current"); return; } - renderControl->stop(); + renderControl->invalidate(); } void QQuickWidgetPrivate::handleWindowChange() { - stopRenderControl(); + invalidateRenderControl(); destroyContext(); } @@ -158,7 +158,7 @@ QQuickWidgetPrivate::~QQuickWidgetPrivate() if (QQmlDebugService::isDebuggingEnabled()) QQmlInspectorService::instance()->removeView(q_func()); - stopRenderControl(); + invalidateRenderControl(); // context and offscreenSurface are current at this stage, if the context was created. Q_ASSERT(!context || (QOpenGLContext::currentContext() == context && context->surface() == offscreenSurface)); @@ -964,7 +964,7 @@ void QQuickWidget::showEvent(QShowEvent *) void QQuickWidget::hideEvent(QHideEvent *) { Q_D(QQuickWidget); - d->stopRenderControl(); + d->invalidateRenderControl(); } /*! \reimp */ diff --git a/src/quickwidgets/qquickwidget_p.h b/src/quickwidgets/qquickwidget_p.h index 356c34e7f5..8a8d98f45e 100644 --- a/src/quickwidgets/qquickwidget_p.h +++ b/src/quickwidgets/qquickwidget_p.h @@ -92,7 +92,7 @@ public: void init(QQmlEngine* e = 0); void handleWindowChange(); - void stopRenderControl(); + void invalidateRenderControl(); QSize rootObjectSize() const; |