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 <rich@kde.org>
Reviewed-by: Peter Hartmann <phartmann@blackberry.com>
This commit is contained in:
Frantisek Vacek 2014-01-31 14:25:46 +01:00 committed by The Qt Project
parent cd820569dc
commit cc88e6e92c

View File

@ -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