summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/corelib/io/qfile.cpp3
-rw-r--r--src/corelib/io/qresource.cpp2
-rw-r--r--tests/auto/qfile/tst_qfile.cpp4
3 files changed, 7 insertions, 2 deletions
diff --git a/src/corelib/io/qfile.cpp b/src/corelib/io/qfile.cpp
index b6fa5f3..6395cc7 100644
--- a/src/corelib/io/qfile.cpp
+++ b/src/corelib/io/qfile.cpp
@@ -1389,6 +1389,9 @@ QFile::close()
bool flushed = flush();
QIODevice::close();
+ // reset write buffer
+ d->lastWasWrite = false;
+ d->writeBuffer.clear();
// keep earlier error from flush
if (fileEngine()->close() && flushed)
diff --git a/src/corelib/io/qresource.cpp b/src/corelib/io/qresource.cpp
index 3d54969..adfbb15 100644
--- a/src/corelib/io/qresource.cpp
+++ b/src/corelib/io/qresource.cpp
@@ -1285,7 +1285,7 @@ bool QResourceFileEngine::close()
bool QResourceFileEngine::flush()
{
- return false;
+ return true;
}
qint64 QResourceFileEngine::read(char *data, qint64 len)
diff --git a/tests/auto/qfile/tst_qfile.cpp b/tests/auto/qfile/tst_qfile.cpp
index 453434d..f407b12 100644
--- a/tests/auto/qfile/tst_qfile.cpp
+++ b/tests/auto/qfile/tst_qfile.cpp
@@ -2119,15 +2119,17 @@ void tst_QFile::fullDisk()
file.write(&c, 0);
QVERIFY(!file.flush());
QCOMPARE(file.error(), QFile::ResourceError);
- file.write(&c, 1);
+ QCOMPARE(file.write(&c, 1), qint64(1));
QVERIFY(!file.flush());
QCOMPARE(file.error(), QFile::ResourceError);
file.close();
QVERIFY(!file.isOpen());
QCOMPARE(file.error(), QFile::ResourceError);
+
file.open(QIODevice::WriteOnly);
QCOMPARE(file.error(), QFile::NoError);
+ QVERIFY(file.flush()); // Shouldn't inherit write buffer
file.close();
QCOMPARE(file.error(), QFile::NoError);