From cc88e6e92c806def34bce8cdcab275934ab646bf Mon Sep 17 00:00:00 2001 From: Frantisek Vacek Date: Fri, 31 Jan 2014 14:25:46 +0100 Subject: QDeclarativeTypeLoader doesn't close processed QNetworkReplies This bug causes that Cascades QML application cannot open more than system ulimit defined number of different asset:///*.qml files. The realFile is ordinary closed in the ~QNetworkReplyFileImpl(), the QDeclarativeTypeLoader::::networkReplyFinished() calls reply->deleteLater(). There are tricky situations when event-loop is not entered and too many read already files are waiting for close. This patch close() file when all the data is read. It can be done this way since the QNetworkReplyFileImplnetworkreply is a sequential device. For more info, please, read comments on QTBUG-36032 Task-number: QTBUG-36032 Change-Id: I4002f21b4b0c7350af48b0dc6530d9606fd2794b Reviewed-by: Richard J. Moore Reviewed-by: Peter Hartmann --- src/network/access/qnetworkreplyfileimpl.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/network/access/qnetworkreplyfileimpl.cpp b/src/network/access/qnetworkreplyfileimpl.cpp index f7555f8fc3..2724a54309 100644 --- a/src/network/access/qnetworkreplyfileimpl.cpp +++ b/src/network/access/qnetworkreplyfileimpl.cpp @@ -161,6 +161,8 @@ void QNetworkReplyFileImpl::abort() qint64 QNetworkReplyFileImpl::bytesAvailable() const { Q_D(const QNetworkReplyFileImpl); + if (!d->realFile.isOpen()) + return QNetworkReply::bytesAvailable(); return QNetworkReply::bytesAvailable() + d->realFile.bytesAvailable(); } @@ -181,7 +183,11 @@ qint64 QNetworkReplyFileImpl::size() const qint64 QNetworkReplyFileImpl::readData(char *data, qint64 maxlen) { Q_D(QNetworkReplyFileImpl); + if (!d->realFile.isOpen()) + return -1; qint64 ret = d->realFile.read(data, maxlen); + if (bytesAvailable() == 0 && d->realFile.isOpen()) + d->realFile.close(); if (ret == 0 && bytesAvailable() == 0) return -1; else -- cgit v1.2.3