summaryrefslogtreecommitdiffstats
path: root/src/corelib
diff options
context:
space:
mode:
authorShane Kearns <shane.kearns@accenture.com>2011-10-20 16:55:02 +0100
committerQt by Nokia <qt-info@nokia.com>2011-10-24 12:30:53 +0200
commit29c30a20bab4c4ea892b95c08c71bb5f136bb82c (patch)
tree40ed1f6fa894b7b1da3de159eedbc77238fe5bc1 /src/corelib
parent28c3d56d4fe8ccd0af9db5b9c39e297f3aed13be (diff)
QIODevice - disallow setTextMode when not open
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) <thiago.macieira@intel.com> Reviewed-by: João Abecasis <joao.abecasis@nokia.com>
Diffstat (limited to 'src/corelib')
-rw-r--r--src/corelib/io/qiodevice.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/corelib/io/qiodevice.cpp b/src/corelib/io/qiodevice.cpp
index 89987bc64a..8e1b2d5d0c 100644
--- a/src/corelib/io/qiodevice.cpp
+++ b/src/corelib/io/qiodevice.cpp
@@ -451,11 +451,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