summaryrefslogtreecommitdiffstats
path: root/src/corelib/io
diff options
context:
space:
mode:
Diffstat (limited to 'src/corelib/io')
-rw-r--r--src/corelib/io/qfile.cpp5
-rw-r--r--src/corelib/io/qiodevice.cpp6
2 files changed, 10 insertions, 1 deletions
diff --git a/src/corelib/io/qfile.cpp b/src/corelib/io/qfile.cpp
index d08574d..cdee7ce 100644
--- a/src/corelib/io/qfile.cpp
+++ b/src/corelib/io/qfile.cpp
@@ -918,6 +918,7 @@ QFile::copy(const QString &newName)
#endif
if (error) {
out.close();
+ close();
d->setError(QFile::CopyError, tr("Cannot open for output"));
} else {
char block[4096];
@@ -928,6 +929,7 @@ QFile::copy(const QString &newName)
break;
totalRead += in;
if(in != out.write(block, in)) {
+ close();
d->setError(QFile::CopyError, tr("Failure to write block"));
error = true;
break;
@@ -941,6 +943,7 @@ QFile::copy(const QString &newName)
}
if (!error && !out.rename(newName)) {
error = true;
+ close();
d->setError(QFile::CopyError, tr("Cannot create %1 for output").arg(newName));
}
#ifdef QT_NO_TEMPORARYFILE
@@ -951,10 +954,10 @@ QFile::copy(const QString &newName)
out.setAutoRemove(false);
#endif
}
- close();
}
if(!error) {
QFile::setPermissions(newName, permissions());
+ close();
unsetError();
return true;
}
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