From 6b088b7a1da37511a8abb1503e4f2f95632dbdac Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 1 Nov 2018 16:35:29 -0700 Subject: [PATCH] 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 Reviewed-by: Lars Knoll --- src/corelib/io/qresource.cpp | 1 - tests/auto/corelib/io/qresourceengine/tst_qresourceengine.cpp | 4 ++++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/corelib/io/qresource.cpp b/src/corelib/io/qresource.cpp index 8c1bfc8c48f..564a3e5f51f 100644 --- a/src/corelib/io/qresource.cpp +++ b/src/corelib/io/qresource.cpp @@ -1288,7 +1288,6 @@ bool QResourceFileEngine::close() { Q_D(QResourceFileEngine); d->offset = 0; - d->uncompressed.clear(); return true; } diff --git a/tests/auto/corelib/io/qresourceengine/tst_qresourceengine.cpp b/tests/auto/corelib/io/qresourceengine/tst_qresourceengine.cpp index 6461e6274f6..0b50c391b87 100644 --- a/tests/auto/corelib/io/qresourceengine/tst_qresourceengine.cpp +++ b/tests/auto/corelib/io/qresourceengine/tst_qresourceengine.cpp @@ -410,6 +410,10 @@ void tst_QResourceEngine::checkStructure() QVERIFY2(ptr, qPrintable(file.errorString())); QByteArray ba = QByteArray::fromRawData(reinterpret_cast(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()); }