diff options
author | Peter Hartmann <phartmann@blackberry.com> | 2014-06-17 11:26:14 (GMT) |
---|---|---|
committer | Peter Hartmann <phartmann@blackberry.com> | 2014-06-18 10:12:46 (GMT) |
commit | 753321eb459d2c988d66cc6c8905d75a0ba769bb (patch) | |
tree | b73dca0f7292d32f07abe5e64eccb8e3f824e52e /src/network/access | |
parent | 1f516d41ebc65dec5c58185a7c5524c230d65c9a (diff) | |
download | Qt-753321eb459d2c988d66cc6c8905d75a0ba769bb.zip Qt-753321eb459d2c988d66cc6c8905d75a0ba769bb.tar.gz Qt-753321eb459d2c988d66cc6c8905d75a0ba769bb.tar.bz2 |
network internals: do not try to cache a deleted entry
We were keeping a dangling pointer to a non-existent QIODevice around
which would lead to a crash.
This is not reproducible in Qt5 anymore.
Task-number: QTBUG-17400
Change-Id: I19af701a42e48c05d04dec18eca9f1bfc7e1f4bb
Reviewed-by: Richard J. Moore <rich@kde.org>
Diffstat (limited to 'src/network/access')
-rw-r--r-- | src/network/access/qnetworkreplyimpl.cpp | 10 | ||||
-rw-r--r-- | src/network/access/qnetworkreplyimpl_p.h | 2 |
2 files changed, 12 insertions, 0 deletions
diff --git a/src/network/access/qnetworkreplyimpl.cpp b/src/network/access/qnetworkreplyimpl.cpp index 0495658..7ee7386 100644 --- a/src/network/access/qnetworkreplyimpl.cpp +++ b/src/network/access/qnetworkreplyimpl.cpp @@ -505,6 +505,13 @@ void QNetworkReplyImplPrivate::_q_cacheDestroyed() cacheEnabled = false; } +void QNetworkReplyImplPrivate::_q_cacheSaveDeviceAboutToClose() +{ + // do not keep a dangling pointer to the device around (device + // is closing because e.g. QAbstractNetworkCache::remove() was called). + cacheSaveDevice = 0; +} + void QNetworkReplyImplPrivate::completeCacheSave() { Q_Q(QNetworkReplyImpl); @@ -565,6 +572,9 @@ void QNetworkReplyImplPrivate::initCacheSaveDevice() cacheSaveDevice = networkCache()->prepare(metaData); + if (cacheSaveDevice) + q->connect(cacheSaveDevice, SIGNAL(aboutToClose()), SLOT(_q_cacheSaveDeviceAboutToClose())); + if (!cacheSaveDevice || (cacheSaveDevice && !cacheSaveDevice->isOpen())) { if (cacheSaveDevice && !cacheSaveDevice->isOpen()) qCritical("QNetworkReplyImpl: network cache returned a device that is not open -- " diff --git a/src/network/access/qnetworkreplyimpl_p.h b/src/network/access/qnetworkreplyimpl_p.h index 3947e79..d59e6a0 100644 --- a/src/network/access/qnetworkreplyimpl_p.h +++ b/src/network/access/qnetworkreplyimpl_p.h @@ -105,6 +105,7 @@ public: Q_PRIVATE_SLOT(d_func(), void _q_networkSessionFailed()) #endif Q_PRIVATE_SLOT(d_func(), void _q_cacheDestroyed()) + Q_PRIVATE_SLOT(d_func(), void _q_cacheSaveDeviceAboutToClose()) }; class QNetworkReplyImplPrivate: public QNetworkReplyPrivate @@ -142,6 +143,7 @@ public: void _q_networkSessionFailed(); #endif void _q_cacheDestroyed(); + void _q_cacheSaveDeviceAboutToClose(); void setup(QNetworkAccessManager::Operation op, const QNetworkRequest &request, QIODevice *outgoingData); |