summaryrefslogtreecommitdiffstats
path: root/src/corelib/io
diff options
context:
space:
mode:
authorxiechyong <chengy.xie@gmail.com>2011-10-28 04:07:26 (GMT)
committerOswald Buddenhagen <oswald.buddenhagen@nokia.com>2011-10-31 10:15:27 (GMT)
commit16f67b49ae5232d4d0fb19e0333f5e2ef2a65449 (patch)
treec1314b19659eeb4a40752e4ed6e18bca4656e8ea /src/corelib/io
parent1b928f5e41888150c4d85ff4df8a9fcab9b06d90 (diff)
downloadQt-16f67b49ae5232d4d0fb19e0333f5e2ef2a65449.zip
Qt-16f67b49ae5232d4d0fb19e0333f5e2ef2a65449.tar.gz
Qt-16f67b49ae5232d4d0fb19e0333f5e2ef2a65449.tar.bz2
Fix QFile::copy() returning false but error() being NoError
Calling close() after setError() will unset the error. Task-number: QTBUG-11982 Merge-request: 2712 Reviewed-by: ossi
Diffstat (limited to 'src/corelib/io')
-rw-r--r--src/corelib/io/qfile.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/corelib/io/qfile.cpp b/src/corelib/io/qfile.cpp
index 06c403a..6f24376 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;
}