From b4723a099337fe52b29a415a5827167ccf4e0923 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ole=20Andr=C3=A9=20Vadla=20Ravn=C3=A5s?= Date: Wed, 29 Jun 2011 03:32:38 +0200 Subject: [PATCH 2/2] network: fix overlapping request crash in network cache logic Fixes crash when creating a cache-invalidating request on QNetworkAccessManager while another request with the same URL is already in progress. http://bugreports.qt.nokia.com/browse/QTBUG-20162 --- src/network/access/qnetworkreplyimpl.cpp | 11 +++++++++++ src/network/access/qnetworkreplyimpl_p.h | 2 ++ 2 files changed, 13 insertions(+), 0 deletions(-) diff --git a/src/network/access/qnetworkreplyimpl.cpp b/src/network/access/qnetworkreplyimpl.cpp index 574b6e9..4fdcbb4 100644 --- a/src/network/access/qnetworkreplyimpl.cpp +++ b/src/network/access/qnetworkreplyimpl.cpp @@ -195,6 +195,12 @@ void QNetworkReplyImplPrivate::_q_bufferOutgoingDataFinished() QMetaObject::invokeMethod(q, "_q_startOperation", Qt::QueuedConnection); } +void QNetworkReplyImplPrivate::_q_cacheDeviceDestroyed() +{ + cacheSaveDevice = 0; + cacheEnabled = false; +} + void QNetworkReplyImplPrivate::_q_bufferOutgoingData() { Q_Q(QNetworkReplyImpl); @@ -537,6 +543,11 @@ void QNetworkReplyImplPrivate::initCacheSaveDevice() cacheSaveDevice = 0; cacheEnabled = false; } + + if (cacheSaveDevice) { + QObject::connect(cacheSaveDevice, SIGNAL(destroyed()), + q, SLOT(_q_cacheDeviceDestroyed())); + } } // we received downstream data and send this to the cache diff --git a/src/network/access/qnetworkreplyimpl_p.h b/src/network/access/qnetworkreplyimpl_p.h index 31da297..7f9693c 100644 --- a/src/network/access/qnetworkreplyimpl_p.h +++ b/src/network/access/qnetworkreplyimpl_p.h @@ -99,6 +99,7 @@ public: Q_PRIVATE_SLOT(d_func(), void _q_copyReadChannelFinished()) Q_PRIVATE_SLOT(d_func(), void _q_bufferOutgoingData()) Q_PRIVATE_SLOT(d_func(), void _q_bufferOutgoingDataFinished()) + Q_PRIVATE_SLOT(d_func(), void _q_cacheDeviceDestroyed()) #ifndef QT_NO_BEARERMANAGEMENT Q_PRIVATE_SLOT(d_func(), void _q_networkSessionConnected()) Q_PRIVATE_SLOT(d_func(), void _q_networkSessionFailed()) @@ -135,6 +136,7 @@ public: void _q_copyReadChannelFinished(); void _q_bufferOutgoingData(); void _q_bufferOutgoingDataFinished(); + void _q_cacheDeviceDestroyed(); #ifndef QT_NO_BEARERMANAGEMENT void _q_networkSessionConnected(); void _q_networkSessionFailed(); -- 1.7.3.4