diff options
author | Ulf Hermann <[email protected]> | 2019-09-30 13:21:47 +0200 |
---|---|---|
committer | Ulf Hermann <[email protected]> | 2019-10-02 11:20:05 +0200 |
commit | abc0fc64b3d797af4d47cd2f7e3df68a3114c120 (patch) | |
tree | cfc11f3a5c8ee5acf03ea3ca8264388435d04782 | |
parent | 50e76d84bf6935e5d517c64c46b32c50d1e14ba9 (diff) |
QQuickWindow: Don't leak the animation controller
There are ways to close the window without hitting the code paths in the
render loops that delete the animation controller. Probably if no frame
was ever rendered.
Change-Id: If3e9d2051525c4ff50eda19084c967578fe4f4b0
Reviewed-by: Simon Hausmann <[email protected]>
12 files changed, 17 insertions, 16 deletions
diff --git a/src/plugins/scenegraph/d3d12/qsgd3d12renderloop.cpp b/src/plugins/scenegraph/d3d12/qsgd3d12renderloop.cpp index 0d501f48c0..4a6894e69e 100644 --- a/src/plugins/scenegraph/d3d12/qsgd3d12renderloop.cpp +++ b/src/plugins/scenegraph/d3d12/qsgd3d12renderloop.cpp @@ -148,7 +148,7 @@ void QSGD3D12RenderLoop::windowDestroyed(QQuickWindow *window) delete rc; delete engine; - delete wd->animationController; + wd->animationController.reset(); } void QSGD3D12RenderLoop::exposeWindow(QQuickWindow *window) diff --git a/src/plugins/scenegraph/d3d12/qsgd3d12threadedrenderloop.cpp b/src/plugins/scenegraph/d3d12/qsgd3d12threadedrenderloop.cpp index f505df1e5a..4302a9119b 100644 --- a/src/plugins/scenegraph/d3d12/qsgd3d12threadedrenderloop.cpp +++ b/src/plugins/scenegraph/d3d12/qsgd3d12threadedrenderloop.cpp @@ -373,7 +373,7 @@ bool QSGD3D12RenderThread::event(QEvent *e) QCoreApplication::processEvents(); QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); if (wme->destroying) - delete wd->animationController; + wd->animationController.reset(); } if (wme->destroying) active = false; @@ -1006,7 +1006,7 @@ void QSGD3D12ThreadedRenderLoop::handleExposure(QQuickWindow *window) if (Q_UNLIKELY(debug_loop())) qDebug("starting render thread"); // Push a few things to the render thread. - QQuickAnimatorController *controller = QQuickWindowPrivate::get(w->window)->animationController; + QQuickAnimatorController *controller = QQuickWindowPrivate::get(w->window)->animationController.data(); if (controller->thread() != w->thread) controller->moveToThread(w->thread); if (w->thread->thread() == QThread::currentThread()) { diff --git a/src/plugins/scenegraph/openvg/qsgopenvgrenderloop.cpp b/src/plugins/scenegraph/openvg/qsgopenvgrenderloop.cpp index 94f7f76036..69b10fcdee 100644 --- a/src/plugins/scenegraph/openvg/qsgopenvgrenderloop.cpp +++ b/src/plugins/scenegraph/openvg/qsgopenvgrenderloop.cpp @@ -96,7 +96,7 @@ void QSGOpenVGRenderLoop::windowDestroyed(QQuickWindow *window) vg->doneCurrent(); } - delete d->animationController; + d->animationController.reset(); } void QSGOpenVGRenderLoop::exposureChanged(QQuickWindow *window) diff --git a/src/quick/items/qquickrendercontrol.cpp b/src/quick/items/qquickrendercontrol.cpp index 83b3372ed9..addd52cb1d 100644 --- a/src/quick/items/qquickrendercontrol.cpp +++ b/src/quick/items/qquickrendercontrol.cpp @@ -188,8 +188,7 @@ void QQuickRenderControlPrivate::windowDestroyed() if (window) { rc->invalidate(); - delete QQuickWindowPrivate::get(window)->animationController; - QQuickWindowPrivate::get(window)->animationController = nullptr; + QQuickWindowPrivate::get(window)->animationController.reset(); #if QT_CONFIG(quick_shadereffect) && QT_CONFIG(opengl) if (QOpenGLContext::currentContext()) diff --git a/src/quick/items/qquickwindow.cpp b/src/quick/items/qquickwindow.cpp index e00789be85..98f5d8a8c1 100644 --- a/src/quick/items/qquickwindow.cpp +++ b/src/quick/items/qquickwindow.cpp @@ -644,7 +644,7 @@ void QQuickWindowPrivate::init(QQuickWindow *c, QQuickRenderControl *control) q->setVulkanInstance(QSGRhiSupport::vulkanInstance()); #endif - animationController = new QQuickAnimatorController(q); + animationController.reset(new QQuickAnimatorController(q)); QObject::connect(context, SIGNAL(initialized()), q, SIGNAL(sceneGraphInitialized()), Qt::DirectConnection); QObject::connect(context, SIGNAL(invalidated()), q, SIGNAL(sceneGraphInvalidated()), Qt::DirectConnection); diff --git a/src/quick/items/qquickwindow_p.h b/src/quick/items/qquickwindow_p.h index becbae7fe3..7d1767c40e 100644 --- a/src/quick/items/qquickwindow_p.h +++ b/src/quick/items/qquickwindow_p.h @@ -254,7 +254,7 @@ public: QSGRenderLoop *windowManager; QQuickRenderControl *renderControl; - QQuickAnimatorController *animationController; + QScopedPointer<QQuickAnimatorController> animationController; QScopedPointer<QTouchEvent> delayedTouch; int pointerEventRecursionGuard; diff --git a/src/quick/scenegraph/adaptations/software/qsgsoftwarerenderloop.cpp b/src/quick/scenegraph/adaptations/software/qsgsoftwarerenderloop.cpp index f5a41410ee..c97dcb9326 100644 --- a/src/quick/scenegraph/adaptations/software/qsgsoftwarerenderloop.cpp +++ b/src/quick/scenegraph/adaptations/software/qsgsoftwarerenderloop.cpp @@ -100,7 +100,7 @@ void QSGSoftwareRenderLoop::windowDestroyed(QQuickWindow *window) rc->invalidate(); } - delete d->animationController; + d->animationController.reset(); } void QSGSoftwareRenderLoop::renderWindow(QQuickWindow *window, bool isNewExpose) diff --git a/src/quick/scenegraph/adaptations/software/qsgsoftwarethreadedrenderloop.cpp b/src/quick/scenegraph/adaptations/software/qsgsoftwarethreadedrenderloop.cpp index 2d4dcd928d..c6b463bb02 100644 --- a/src/quick/scenegraph/adaptations/software/qsgsoftwarethreadedrenderloop.cpp +++ b/src/quick/scenegraph/adaptations/software/qsgsoftwarethreadedrenderloop.cpp @@ -292,7 +292,7 @@ bool QSGSoftwareRenderThread::event(QEvent *e) QCoreApplication::processEvents(); QCoreApplication::sendPostedEvents(nullptr, QEvent::DeferredDelete); if (wme->destroying) - delete wd->animationController; + wd->animationController.reset(); } if (wme->destroying) active = false; @@ -844,7 +844,8 @@ void QSGSoftwareThreadedRenderLoop::handleExposure(QQuickWindow *window) if (!w->thread->isRunning()) { qCDebug(QSG_RASTER_LOG_RENDERLOOP, "starting render thread"); // Push a few things to the render thread. - QQuickAnimatorController *controller = QQuickWindowPrivate::get(w->window)->animationController; + QQuickAnimatorController *controller + = QQuickWindowPrivate::get(w->window)->animationController.get(); if (controller->thread() != w->thread) controller->moveToThread(w->thread); if (w->thread->thread() == QThread::currentThread()) { diff --git a/src/quick/scenegraph/qsgrenderloop.cpp b/src/quick/scenegraph/qsgrenderloop.cpp index e69d25aab3..ba231f8159 100644 --- a/src/quick/scenegraph/qsgrenderloop.cpp +++ b/src/quick/scenegraph/qsgrenderloop.cpp @@ -436,7 +436,7 @@ void QSGGuiThreadRenderLoop::windowDestroyed(QQuickWindow *window) gl->doneCurrent(); } - delete d->animationController; + d->animationController.reset(); } void QSGGuiThreadRenderLoop::handleDeviceLoss() diff --git a/src/quick/scenegraph/qsgthreadedrenderloop.cpp b/src/quick/scenegraph/qsgthreadedrenderloop.cpp index 3689f6501f..86d9590863 100644 --- a/src/quick/scenegraph/qsgthreadedrenderloop.cpp +++ b/src/quick/scenegraph/qsgthreadedrenderloop.cpp @@ -564,7 +564,7 @@ void QSGRenderThread::invalidateGraphics(QQuickWindow *window, bool inDestructor QCoreApplication::processEvents(); QCoreApplication::sendPostedEvents(nullptr, QEvent::DeferredDelete); if (inDestructor) - delete dd->animationController; + dd->animationController.reset(); if (current && gl) gl->doneCurrent(); qCDebug(QSG_LOG_RENDERLOOP, QSG_RT_PAD, "- invalidating scene graph"); @@ -1302,7 +1302,8 @@ void QSGThreadedRenderLoop::handleExposure(QQuickWindow *window) } } - QQuickAnimatorController *controller = QQuickWindowPrivate::get(w->window)->animationController; + QQuickAnimatorController *controller + = QQuickWindowPrivate::get(w->window)->animationController.get(); if (controller->thread() != w->thread) controller->moveToThread(w->thread); diff --git a/src/quick/scenegraph/qsgwindowsrenderloop.cpp b/src/quick/scenegraph/qsgwindowsrenderloop.cpp index 220c70c299..5b48b86568 100644 --- a/src/quick/scenegraph/qsgwindowsrenderloop.cpp +++ b/src/quick/scenegraph/qsgwindowsrenderloop.cpp @@ -269,7 +269,7 @@ void QSGWindowsRenderLoop::windowDestroyed(QQuickWindow *window) m_gl->doneCurrent(); } - delete d->animationController; + d->animationController.reset(); } bool QSGWindowsRenderLoop::anyoneShowing() const diff --git a/src/quick/util/qquickanimatorjob.cpp b/src/quick/util/qquickanimatorjob.cpp index 03be78ab15..a9caedec4f 100644 --- a/src/quick/util/qquickanimatorjob.cpp +++ b/src/quick/util/qquickanimatorjob.cpp @@ -207,7 +207,7 @@ void QQuickAnimatorProxyJob::setWindow(QQuickWindow *window) stop(); } else if (!m_controller && m_job) { - m_controller = QQuickWindowPrivate::get(window)->animationController; + m_controller = QQuickWindowPrivate::get(window)->animationController.get(); if (window->isSceneGraphInitialized()) readyToAnimate(); else |