diff options
author | Laszlo Agocs <laszlo.agocs@theqtcompany.com> | 2015-12-08 14:07:12 +0100 |
---|---|---|
committer | Laszlo Agocs <laszlo.agocs@theqtcompany.com> | 2015-12-09 08:09:28 +0000 |
commit | 177050862e644f9a279086b703cb04e06ea409b8 (patch) | |
tree | bc35343651f96e31e8ee50a792375d27487250b9 | |
parent | 264b9c39b97132ccbaf7d51a8128cca0dca2a64a (diff) |
Clean up correctly in rendercontrol to avoid crashes
Not destroying the Animator controller leads to scenegraph animators
running even after destroying the rendercontrol and the window. Add
the missing delete call and fix the somewhat broken cleanup sequence.
Task-number: QTBUG-49635
Change-Id: I170b4bb4b065bda46d8ab9ad9a3992bc8cfd1d1e
Reviewed-by: Gunnar Sletta <gunnar@sletta.org>
-rw-r--r-- | src/quick/items/qquickrendercontrol.cpp | 19 | ||||
-rw-r--r-- | src/quick/items/qquickrendercontrol_p.h | 1 |
2 files changed, 13 insertions, 7 deletions
diff --git a/src/quick/items/qquickrendercontrol.cpp b/src/quick/items/qquickrendercontrol.cpp index cc4cec443a..d00b02c005 100644 --- a/src/quick/items/qquickrendercontrol.cpp +++ b/src/quick/items/qquickrendercontrol.cpp @@ -129,11 +129,6 @@ QQuickRenderControlPrivate::QQuickRenderControlPrivate() rc = new QSGRenderContext(sg); } -QQuickRenderControlPrivate::~QQuickRenderControlPrivate() -{ - delete rc; -} - void QQuickRenderControlPrivate::cleanup() { delete sg; @@ -162,13 +157,25 @@ QQuickRenderControl::~QQuickRenderControl() if (d->window) QQuickWindowPrivate::get(d->window)->renderControl = 0; + + // It is likely that the cleanup in windowDestroyed() is not called since + // the standard pattern is to destroy the rendercontrol before the QQuickWindow. + // Do it here. + d->windowDestroyed(); + + delete d->rc; } void QQuickRenderControlPrivate::windowDestroyed() { - if (window == 0) { + if (window) { rc->invalidate(); QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); + + delete QQuickWindowPrivate::get(window)->animationController; + QQuickWindowPrivate::get(window)->animationController = 0; + + window = 0; } } diff --git a/src/quick/items/qquickrendercontrol_p.h b/src/quick/items/qquickrendercontrol_p.h index 8837ed79dc..6fe475bb93 100644 --- a/src/quick/items/qquickrendercontrol_p.h +++ b/src/quick/items/qquickrendercontrol_p.h @@ -56,7 +56,6 @@ public: Q_DECLARE_PUBLIC(QQuickRenderControl) QQuickRenderControlPrivate(); - ~QQuickRenderControlPrivate(); static QQuickRenderControlPrivate *get(QQuickRenderControl *renderControl) { return renderControl->d_func(); |