From f986c0c3390ba7d033b6e6276f63dcd4818adb5c Mon Sep 17 00:00:00 2001 From: Albert Astals Cid Date: Thu, 29 Sep 2016 17:35:31 +0200 Subject: Fix crash on cancel QQuickImageResponse We don't need to deleteLater here, we can not be sure that the response won't continue for a bit after this, and it's not even needed since documentation says you need to emit finished in all cases and this will call deleteLater on the response anyway. Task-number: QTBUG-56056 Change-Id: I7cc90620f499beaaaaa61aac77d72d067308838c Reviewed-by: Michael Brasser --- src/quick/util/qquickpixmapcache.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'src/quick/util/qquickpixmapcache.cpp') diff --git a/src/quick/util/qquickpixmapcache.cpp b/src/quick/util/qquickpixmapcache.cpp index 230c31807c..50b6de25fb 100644 --- a/src/quick/util/qquickpixmapcache.cpp +++ b/src/quick/util/qquickpixmapcache.cpp @@ -584,7 +584,6 @@ void QQuickPixmapReader::processJobs() if (asyncResponse) { asyncResponses.remove(asyncResponse); asyncResponse->cancel(); - asyncResponse->deleteLater(); } } PIXMAP_PROFILE(pixmapStateChanged(job->url)); -- cgit v1.2.3 From 4ee2bc4e9c05d8daec8b04412a0b7c0264fbc1a4 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Mon, 15 Aug 2016 10:35:53 +0200 Subject: Turn the no-network support into a configurable feature Change-Id: Ic70f60c124fe166b37fbe9b853735be3c5e0d46d Reviewed-by: Oswald Buddenhagen Reviewed-by: Simon Hausmann --- src/quick/util/qquickpixmapcache.cpp | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'src/quick/util/qquickpixmapcache.cpp') diff --git a/src/quick/util/qquickpixmapcache.cpp b/src/quick/util/qquickpixmapcache.cpp index 9722bf544b..46f6cccc62 100644 --- a/src/quick/util/qquickpixmapcache.cpp +++ b/src/quick/util/qquickpixmapcache.cpp @@ -67,7 +67,7 @@ #include #include -#ifndef QT_NO_NETWORK +#if QT_CONFIG(qml_network) #include #include #include @@ -206,7 +206,7 @@ private: friend class QQuickPixmapReaderThreadObject; void processJobs(); void processJob(QQuickPixmapReply *, const QUrl &, const QString &, AutoTransform, QQuickImageProvider::ImageType, QQuickImageProvider *); -#ifndef QT_NO_NETWORK +#if QT_CONFIG(qml_network) void networkRequestDone(QNetworkReply *); #endif void asyncResponseFinished(QQuickImageResponse *); @@ -220,7 +220,7 @@ private: QQuickPixmapReaderThreadObject *threadObject; QWaitCondition waitCondition; -#ifndef QT_NO_NETWORK +#if QT_CONFIG(qml_network) QNetworkAccessManager *networkAccessManager(); QNetworkAccessManager *accessManager; QHash networkJobs; @@ -349,7 +349,7 @@ QQuickPixmapReply::Event::~Event() delete textureFactory; } -#ifndef QT_NO_NETWORK +#if QT_CONFIG(qml_network) QNetworkAccessManager *QQuickPixmapReader::networkAccessManager() { if (!accessManager) { @@ -430,7 +430,7 @@ static bool readImage(const QUrl& url, QIODevice *dev, QImage *image, QString *e QQuickPixmapReader::QQuickPixmapReader(QQmlEngine *eng) : QThread(eng), engine(eng), threadObject(0) -#ifndef QT_NO_NETWORK +#if QT_CONFIG(qml_network) , accessManager(0) #endif { @@ -454,7 +454,7 @@ QQuickPixmapReader::~QQuickPixmapReader() delete reply; } jobs.clear(); -#ifndef QT_NO_NETWORK +#if QT_CONFIG(qml_network) const auto cancelJob = [this](QQuickPixmapReply *reply) { if (reply->loading) { @@ -476,7 +476,7 @@ QQuickPixmapReader::~QQuickPixmapReader() wait(); } -#ifndef QT_NO_NETWORK +#if QT_CONFIG(qml_network) void QQuickPixmapReader::networkRequestDone(QNetworkReply *reply) { QQuickPixmapReply *job = networkJobs.take(reply); @@ -526,7 +526,7 @@ void QQuickPixmapReader::networkRequestDone(QNetworkReply *reply) // kick off event loop again incase we have dropped below max request count threadObject->processJobs(); } -#endif // QT_NO_NETWORK +#endif // qml_network void QQuickPixmapReader::asyncResponseFinished(QQuickImageResponse *response) { @@ -577,7 +577,7 @@ bool QQuickPixmapReaderThreadObject::event(QEvent *e) void QQuickPixmapReaderThreadObject::networkRequestDone() { -#ifndef QT_NO_NETWORK +#if QT_CONFIG(qml_network) QNetworkReply *reply = static_cast(sender()); reader->networkRequestDone(reply); #endif @@ -599,7 +599,7 @@ void QQuickPixmapReader::processJobs() // Clean cancelled jobs if (!cancelled.isEmpty()) { -#ifndef QT_NO_NETWORK +#if QT_CONFIG(qml_network) for (int i = 0; i < cancelled.count(); ++i) { QQuickPixmapReply *job = cancelled.at(i); QNetworkReply *reply = networkJobs.key(job, 0); @@ -644,7 +644,7 @@ void QQuickPixmapReader::processJobs() } else { localFile = QQmlFile::urlToLocalFileOrQrc(url); usableJob = !localFile.isEmpty() -#ifndef QT_NO_NETWORK +#if QT_CONFIG(qml_network) || networkJobs.count() < IMAGEREQUEST_MAX_NETWORK_REQUEST_COUNT #endif ; @@ -772,7 +772,7 @@ void QQuickPixmapReader::processJob(QQuickPixmapReply *runningJob, const QUrl &u runningJob->postReply(errorCode, errorStr, readSize, QQuickTextureFactory::textureFactoryForImage(image)); mutex.unlock(); } else { -#ifndef QT_NO_NETWORK +#if QT_CONFIG(qml_network) // Network resource QNetworkRequest req(url); req.setAttribute(QNetworkRequest::HttpPipeliningAllowedAttribute, true); @@ -841,7 +841,7 @@ void QQuickPixmapReader::cancel(QQuickPixmapReply *reply) void QQuickPixmapReader::run() { if (replyDownloadProgress == -1) { -#ifndef QT_NO_NETWORK +#if QT_CONFIG(qml_network) replyDownloadProgress = QMetaMethod::fromSignal(&QNetworkReply::downloadProgress).methodIndex(); replyFinished = QMetaMethod::fromSignal(&QNetworkReply::finished).methodIndex(); const QMetaObject *ir = &QQuickPixmapReaderThreadObject::staticMetaObject; -- cgit v1.2.3