Warning, /graphics/krita/3rdparty/ext_qt/0080-Sync-buffers-of-the-destination-file-after-QFile-cop.patch is written in an unsupported language. File is not indexed.
0001 From 1ff6def2f34072920092ec857c2deaf057ffb48a Mon Sep 17 00:00:00 2001 0002 From: Dmitry Kazakov <dimula73@gmail.com> 0003 Date: Thu, 3 Oct 2019 19:20:07 +0300 0004 Subject: [PATCH 22/47] Sync buffers of the destination file after 0005 QFile::copy() 0006 0007 After doing native file copying operating system (tested on Windows) 0008 doesn't sync the buffers of the file for some time. That is, if the 0009 user faces ome power outage, the file will be lost. 0010 0011 Actually, the other (non-native) copying option already has buffers 0012 syncing code. So this patch also makes behavior a bit more consistent. 0013 0014 Change-Id: Id1b716ae86f68303ef6a9745a3275628d91e2d93 0015 --- 0016 src/corelib/io/qfile.cpp | 13 +++++++++++++ 0017 1 file changed, 13 insertions(+) 0018 0019 diff --git a/src/corelib/io/qfile.cpp b/src/corelib/io/qfile.cpp 0020 index 1fb9af576c..c0d9415871 100644 0021 --- a/src/corelib/io/qfile.cpp 0022 +++ b/src/corelib/io/qfile.cpp 0023 @@ -784,6 +784,19 @@ QFile::copy(const QString &newName) 0024 close(); 0025 if(error() == QFile::NoError) { 0026 if (d->engine()->copy(newName)) { 0027 + /** 0028 + * Force copied file to be synched to disk, like we do it in 0029 + * alternative approach 0030 + */ 0031 + QFile out(newName); 0032 + if (out.open(QIODevice::ReadWrite)) { 0033 + bool result = out.d_func()->engine()->syncToDisk(); 0034 + out.close(); 0035 + } else { 0036 + d->setError(QFile::CopyError, tr("Cannot open %1 for output").arg(newName)); 0037 + return false; 0038 + } 0039 + 0040 unsetError(); 0041 return true; 0042 } else { 0043 -- 0044 2.20.1.windows.1 0045