diff options
Diffstat (limited to 'src/corelib/io/qfile.cpp')
-rw-r--r-- | src/corelib/io/qfile.cpp | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/src/corelib/io/qfile.cpp b/src/corelib/io/qfile.cpp index ef97d67653..37de4450cc 100644 --- a/src/corelib/io/qfile.cpp +++ b/src/corelib/io/qfile.cpp @@ -844,10 +844,16 @@ QFile::copy(const QString &newName) error = true; } } - if (!error && !out.rename(newName)) { - error = true; - close(); - d->setError(QFile::CopyError, tr("Cannot create %1 for output").arg(newName)); + + if (!error) { + // Sync to disk if possible. Ignore errors (e.g. not supported). + d->fileEngine->syncToDisk(); + + if (!out.rename(newName)) { + error = true; + close(); + d->setError(QFile::CopyError, tr("Cannot create %1 for output").arg(newName)); + } } #ifdef QT_NO_TEMPORARYFILE if (error) |