I have been looking into the recent issues with data loss on file saves.
After a little more investigation it looks like this is was as a result
of a Qt bug that was fixed in Qt 4.5.1. See the bug report and commit here,
The original Windows binary I made had Qt 4.5.0 DLLs, instead of the
4.5.1 DLLs. This meant that QFile::rename did not set the file name to
the new name when it was successful. This then led to the deletion of
the original file, Avogadro followed the sequence,
- Write to ‘filename.cml.new’ with new data
- Move original file to ‘filename.cml.old’
- Move ‘filename.cml.new’ to ‘filename.cml’
- Remove ‘filename.cml.old’ - this is where it failed
The QFile retained the original file name, ‘filename.cml’ which was then
the file that had just been saved. See the commit I made yesterday.
Among other things I explicitly set the file name of the QFile object
after a successful rename. This just duplicates what Qt does in >4.5.1.
As we cannot be sure what Qt version the Linux distributions will use,
and that they are the main consumers of our source tarballs, (along with
interested users compiling Avogadro independently) I would like to tag
and release Avogadro 0.9.6 today. With very few changes, mainly to
ensure Linux packages are not hit by this bug.
The Mac package embeds Qt 4.5.1, and the Windows packages have this
patch and Qt 4.5.1. So neither of them are affected by this bug, nor is
any Linux distribution that has Qt 4.5.1 (made this a little harder for
me to track down).
I think bumping the version will also help to ensure Windows users grab
the new binaries, and to test out the new update checker I wrote.