From: Albert Astals Cid Date: Fri, 14 Aug 2015 13:51:43 +0000 (+0200) Subject: Fix memory leak when QQuickPixmapReply::Event is delete before being used X-Git-Tag: v5.5.90+alpha1~3^2~7 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=16916560c13bf4c096461426c37eccbc8841a13c;p=platform%2Fupstream%2Fqtdeclarative.git Fix memory leak when QQuickPixmapReply::Event is delete before being used It can happen that QQuickPixmapReply::postReply is called, and before QQuickPixmapReply::event is called the object gets deleted. That means that the texture factory will never be deleted. To fix that we delete it in the destructor of QQuickPixmapReply::Event and set it to 0 in QQuickPixmapReply::event after assigning to the next data structure that will take care of it Change-Id: Ibea62f5a10a53cca586de7c5f03f00aabfb88b2e Reviewed-by: Robin Burchell --- diff --git a/src/quick/util/qquickpixmapcache.cpp b/src/quick/util/qquickpixmapcache.cpp index ddf2ae239..a1c920553 100644 --- a/src/quick/util/qquickpixmapcache.cpp +++ b/src/quick/util/qquickpixmapcache.cpp @@ -148,6 +148,7 @@ public: class Event : public QEvent { public: Event(ReadError, const QString &, const QSize &, AutoTransform, QQuickTextureFactory *factory); + ~Event(); ReadError error; QString errorString; @@ -339,6 +340,11 @@ QQuickPixmapReply::Event::Event(ReadError e, const QString &s, const QSize &iSiz { } +QQuickPixmapReply::Event::~Event() +{ + delete textureFactory; +} + QNetworkAccessManager *QQuickPixmapReader::networkAccessManager() { if (!accessManager) { @@ -965,6 +971,7 @@ bool QQuickPixmapReply::event(QEvent *event) data->pixmapStatus = (de->error == NoError) ? QQuickPixmap::Ready : QQuickPixmap::Error; if (data->pixmapStatus == QQuickPixmap::Ready) { data->textureFactory = de->textureFactory; + de->textureFactory = 0; data->implicitSize = de->implicitSize; data->appliedTransform = de->autoTransform; PIXMAP_PROFILE(pixmapLoadingFinished(data->url,