From e5df3b4eeaf5943f5170dda781c3c589fa35a15a Mon Sep 17 00:00:00 2001 From: Shane Kearns Date: Thu, 20 Oct 2011 16:55:02 +0100 Subject: QIODevice - disallow setTextMode when not open MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Calling setTextMode() before open() would make the device appear to be already open and cause later errors. Added a qWarning and documentation update to prevent this API misuse Task-number: QTBUG-20905 Change-Id: I2e06cd8e79f4afcf27417ac0eae6ebef980a17aa Reviewed-by: Thiago Macieira (Intel) Reviewed-by: João Abecasis (cherry picked from commit 29c30a20bab4c4ea892b95c08c71bb5f136bb82c) --- src/corelib/io/qiodevice.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/corelib/io/qiodevice.cpp b/src/corelib/io/qiodevice.cpp index dae4e82..56fff90 100644 --- a/src/corelib/io/qiodevice.cpp +++ b/src/corelib/io/qiodevice.cpp @@ -468,11 +468,17 @@ void QIODevice::setOpenMode(OpenMode openMode) otherwise the \l Text flag is removed. This feature is useful for classes that provide custom end-of-line handling on a QIODevice. + The IO device should be opened before calling this function. + \sa open(), setOpenMode() */ void QIODevice::setTextModeEnabled(bool enabled) { Q_D(QIODevice); + if (!isOpen()) { + qWarning("QIODevice::setTextModeEnabled: The device is not open"); + return; + } if (enabled) d->openMode |= Text; else -- cgit v0.12