-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
QSaveFile: make it so flush() errors imply commit() failed
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 92373d3) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> (cherry picked from commit 09d44fd)
- Loading branch information
1 parent
1bdef60
commit f3fc371
Showing
3 changed files
with
144 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters