QSaveFile records past write errors in writeData(), but often the QFileDevice::writeData() calls it places will succeed because the data is only being buffered. Instead, the failures are noticed only by flush(), whose actions do not affect QSaveFilePrivate::writeError. [ChangeLog][QtCore][QSaveFile] Fixed a bug that caused commit() to return true and overwrite its intended target file even though it failed to flush buffered data to the storage, which could cause data loss. This issue can be worked around by calling flush() first and only calling commit() if that returns success. [ChangeLog][QtCore][QSaveFile] Fixed a bug that caused commit() to return true even after a cancelWriting() call had been placed, if writing directly to the target file (that is, only with setDirectWriteFallback() set to true). Note that the state of the file does not change under those conditions, only the value returned by the function. Drive-by clarify a comment from 6bf1674f1e51fd8b08783035cda7493ecd63b44 (Qt 4.6 "Don't drop errors from flush on QFile::close") which had me chasing the wrong lead. Fixes: QTBUG-132332 Pick-to: 6.5 5.15 Change-Id: I427df6fd02132d02be91fffd175579c35b9c06cc Reviewed-by: David Faure <david.faure@kdab.com> Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de> (cherry picked from commit 92373d353cf090faa03cbc8aca505d1784b10b54) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> (cherry picked from commit 09d44fdef3acf4146a26d6ae757eb2915b29f147) |
||
|---|---|---|
| .. | ||
| animation | ||
| global | ||
| io | ||
| ipc | ||
| itemmodels | ||
| kernel | ||
| mimetypes | ||
| platform | ||
| plugin | ||
| serialization | ||
| text | ||
| thread | ||
| time | ||
| tools | ||
| CMakeLists.txt | ||