From 695a9605c6575eafe535c2dbfe94ad3e7697a5a8 Mon Sep 17 00:00:00 2001 From: Gunnar Sletta Date: Sat, 23 Aug 2014 14:24:05 +0200 Subject: [PATCH] Make use of QQuickWindowQObjectCleanup in QQuickImage. Saves us a few lines.. Change-Id: I572f6fc44ede3b923208ce3563116d8fcc9bb922 Reviewed-by: Laszlo Agocs --- src/quick/items/qquickimage.cpp | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/src/quick/items/qquickimage.cpp b/src/quick/items/qquickimage.cpp index ff34fda..073b107 100644 --- a/src/quick/items/qquickimage.cpp +++ b/src/quick/items/qquickimage.cpp @@ -93,14 +93,6 @@ QQuickImagePrivate::QQuickImagePrivate() { } -class QQuickImageCleanup : public QRunnable -{ -public: - QQuickImageCleanup(QQuickImageTextureProvider *p) : provider(p) { } - void run() Q_DECL_OVERRIDE { delete provider; } - QQuickImageTextureProvider *provider; -}; - /*! \qmltype Image \instantiates QQuickImage @@ -172,11 +164,10 @@ QQuickImage::QQuickImage(QQuickImagePrivate &dd, QQuickItem *parent) QQuickImage::~QQuickImage() { Q_D(QQuickImage); - if (QQuickWindow *w = window()) { - w->scheduleRenderJob(new QQuickImageCleanup(d->provider), QQuickWindow::AfterSynchronizingStage); - } else { - // Should have been released already in releaseResources or in invalidateSG. - Q_ASSERT(!d->provider); + if (d->provider) { + // We're guaranteed to have a window() here because the provider would have + // been released in releaseResources() if we were gone from a window. + QQuickWindowQObjectCleanupJob::schedule(window(), d->provider); } } @@ -589,7 +580,7 @@ void QQuickImage::releaseResources() { Q_D(QQuickImage); if (d->provider) { - window()->scheduleRenderJob(new QQuickImageCleanup(d->provider), QQuickWindow::AfterSynchronizingStage); + QQuickWindowQObjectCleanupJob::schedule(window(), d->provider); d->provider = 0; } } -- 2.7.4