QResourceFileEngine: fix use of mapped files after close()

QFile::map() is documented to continue working after the QFile is
closed, so this should work for the resource file engine too.

Change-Id: I343f2beed55440a7ac0bfffd1563243a3966441f
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
This commit is contained in:
Thiago Macieira 2018-11-01 16:35:29 -07:00 committed by Liang Qi
parent 6a792d6f0b
commit 6b088b7a1d
2 changed files with 4 additions and 1 deletions

View File

@ -1288,7 +1288,6 @@ bool QResourceFileEngine::close()
{
Q_D(QResourceFileEngine);
d->offset = 0;
d->uncompressed.clear();
return true;
}

View File

@ -410,6 +410,10 @@ void tst_QResourceEngine::checkStructure()
QVERIFY2(ptr, qPrintable(file.errorString()));
QByteArray ba = QByteArray::fromRawData(reinterpret_cast<const char *>(ptr), file.size());
QCOMPARE(ba, contents);
// check that it is still valid after closing the file
file.close();
QCOMPARE(ba, contents);
}
QLocale::setDefault(QLocale::system());
}