diff options
author | Lars Knoll <lars.knoll@theqtcompany.com> | 2015-11-27 13:28:45 +0100 |
---|---|---|
committer | Lars Knoll <lars.knoll@theqtcompany.com> | 2016-03-08 08:59:19 +0000 |
commit | d0b54cede8d8ea0b8431c64abb51d0cd1a71327b (patch) | |
tree | 19920140690359aedc71133153d7580f1c8fb4ee /tests/auto/corelib | |
parent | f2bd0d119200d5b66069725563f7f12952e66da8 (diff) |
Ensure QTextStream doesn't modify the Text flag on the underlying iodevice
An empty read or a failed write on the underlying QIODevice of the text
stream would lead to an early return where we wouldn't correctly restore
the QIODevice::Text flag of the io device.
Change-Id: I5b632f45dea6ede3f408113556c3dad1b96574e2
Task-number: QTBUG-47176
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
Diffstat (limited to 'tests/auto/corelib')
-rw-r--r-- | tests/auto/corelib/io/qtextstream/tst_qtextstream.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/auto/corelib/io/qtextstream/tst_qtextstream.cpp b/tests/auto/corelib/io/qtextstream/tst_qtextstream.cpp index 3ab53848d8..a0348f3c54 100644 --- a/tests/auto/corelib/io/qtextstream/tst_qtextstream.cpp +++ b/tests/auto/corelib/io/qtextstream/tst_qtextstream.cpp @@ -228,6 +228,8 @@ private slots: void alignAccountingStyle(); void setCodec(); + void textModeOnEmptyRead(); + private: void generateLineData(bool for_QString); void generateAllData(bool for_QString); @@ -3045,6 +3047,21 @@ void tst_QTextStream::int_write_with_locale() QCOMPARE(result, output); } +void tst_QTextStream::textModeOnEmptyRead() +{ + const QString filename("textmodetest.txt"); + QFile::remove(filename); // Remove file if exists + + + QFile file(filename); + QVERIFY(file.open(QIODevice::ReadWrite | QIODevice::Text)); + QTextStream stream(&file); + QVERIFY(file.isTextModeEnabled()); + QString emptyLine = stream.readLine(); // Text mode flag cleared here + QVERIFY(file.isTextModeEnabled()); +} + + // ------------------------------------------------------------------------------ QTEST_MAIN(tst_QTextStream) |