Everytime QSettings syncs to disk using the IniFormat (which can be frequent), it resizes the current file to 0 and rewrites it from scratch. This approach can cause problems. First of all, if the application is killed before it can write the new file, all original settings will be lost. Secondly, modern file systems like ext4 have a cache and changes to the file might be incomplete if the machine loses power. Finally, if there is not enough space on disk to rewrite the original settings, the file is unfortunately wipe out again. This is why other programs like "vi" will create a swap file and atomically replace files.
The reason we are reporting this is that we encountered a rare bug in our application where we lose all original settings in the .conf files and we strongly suspect this is the reason. I created a patch against qt 4.5.3 that you will found attached to this bug report. The drawback of this patch is that you need enough space on disk to write the swap file but this is preferable to the risk on losing important settings in the original configuration file.
- relates to
QTBUG-44086 Regression: QSettings create new file with too restrictive permissions
- resulted in
QTCREATORBUG-15594 Resizing columns in debugger stack/breakpoints causes IO Write
|For Gerrit Dashboard: QTBUG-21739|
|86393,16||QSettings: use QSaveFile and QLockFile to write the settings||dev||qt/qtbase||Status: MERGED||+2||0|