Lmms: LMMS file save fail

Created on 1 Aug 2018  Â·  20Comments  Â·  Source: LMMS/lmms

LMMS occasionally fails to save. I was bumped about this issue on Discord (@DouglasDGI) but I've seen cases on the old forum and also noticed it myself. I saw it once with a recover.mmp and I may have mentioned this at the occasion in a thread on GitHub. In the case presented on discord the file was verified to have a size of 0 bytes.

Examples:
Can't save projects on Mac osx
Trouble with saving projects on Mac OSX

When writing a file, we do test for it being larger than 0 bytes here:

if( QFileInfo( outfile.fileName() ).size() > 0 )

If going by size like this, maybe we could bump the zero to 100 or so, as the minimum file size with header seem to be at least a hundred bytes.

bug core

All 20 comments

When failing to open a file for save in DataFile::writeFile() we return a textbox with a confirm button. When failing the save later in that function we return a bool and when called from Song::guiSaveProject() this results in a simple TextFloat and that may not be enough information.

    else if( gui != nullptr )
    {
        TextFloat::displayMessage( tr( "Project NOT saved." ),
                tr( "The project %1 was not saved!" ).arg(
                            m_fileName ),
                embed::getIconPixmap( "error" ), 4000 );
        return false;
    }
  • if( QFileInfo( outfile.fileName() ).size() > 0 )

If this works as intended the function will return false and there will now be a size 0 file left named .new. I've failed to replicate an empty project by creating an empty .new file with
$ touch test.mmp.new
and then trying to save test.mmp in various ways. test.mmp has so far been written correctly and test.mmp.new is removed.

this results in a simple TextFloat and that may not be enough information.

Agreed.

I've failed to replicate an empty project by creating an empty .new file

It's because we overwrite the .new file if already exists.

However, I can't figure out how can it happen. QFile::rename will restore the original file when renaming fails.

Earlier issue (2015) mentioning data loss. https://github.com/LMMS/lmms/issues/2128
So this issue could be there already in stable-1.1 .

There have been no significant changes in DataFile::writeFile since 1.0. The only potential issue I can find is not checking return values of QFile::remove and QFile::rename.
So I'm bumping this issue to 1.3. However, we may address the potential problem in 1.2.

We may also add some more checks like comparing the size of the mmp/mmpz file with the size of the original data. How about adding more checks and then looking for any issues?

Yes to more checks.

There have been no significant changes in DataFile::writeFile since 1.0.

No, but does the bug need to be there?

Idea. Some of the cases with saves gone wrong has been when saving while lmms is malfunctioning. Maybe most or even all of the cases are? What if we issue a test for lmms to perform to see if none of its processes are hung before continuing with a save. Is that possible?

What if we issue a test...

Good idea! but i also suggest that the message LMMS casts when not saving successful, is shown on fire-red background! Currently both the 'success' & 'Failure' message are black/white, and next to identical -This has been agreed earlier, btw
Since this of critical value to the user, i would vote this to be added in 1.2

I've had this occur twice this year, this is pretty irritating

I've had this occur twice this year, this is pretty irritating

What OS ?
1.2.1 or earlier version?
Do you remember anything else about the situation, like what you just did before or similar
Did you

  • Use ctrl+s
  • Used speedbar icon
  • Used Menu
    Can tell you that i never had a fail-save from 2006 to now..

image

What OS ?

Ubuntu Studio 19.10

1.2.1 or earlier version?

1.2.1, AppImage from lmms.io

Do you remember anything else about the situation, like what you just did before or similar

I had low laptop battery, saved and shut off my computer both times. I hit CTRL-S.

Can tell you that i _never_ had a fail-save from 2006 to now..

Code changes in time. I never had this happen to me in 1.1.3.
I skipped 1.2.0 but I tried a 1.2 release candidate a while ago.

When you shut off your computer, did you shut it down properly through the OS, or just turn off the power? It's quite common for OSes to cache files before writing them to disk, and if the computer loses power before they are written for real, the contents can be lost. People have lost projects this way before.

I had low laptop battery

Properly why. If you can, always plugin, and then save

When you shut off your computer, did you shut it down properly through the OS, or just turn off the power?

I did shut off the laptop by forcing it to shut down by holding down the power button. (bad habit...)

It's quite common for OSes to cache files before writing them to disk, and if the computer loses power before they are written for real, the contents can be lost.

I never knew! Is that for reducing the amount of disk read/writes in case of several disk operations occurring in a small timespan? If so, very clever. Otherwise, interesting nonetheless.

It's quite common for OSes to cache files before writing them to disk, and if the computer loses power before they are written for real, the contents can be lost.

I never knew! Is that for reducing the amount of disk read/writes in case of several disk operations occurring in a small timespan? If so, very clever. Otherwise, interesting nonetheless.

Correct, it will try to write in one sweep so it doesn't hit the hard drive all the time (reducing lifespan).

https://doc.qt.io/qt-5/qsavefile.html (since Qt 5.1)

_While writing, the contents will be written to a temporary file, and if no error happened, commit() will move it to the final file. This ensures that no data at the final file is lost in case an error happens while writing, and no partially-written file is ever present at the final location. Always use QSaveFile when saving entire documents to disk._

lmms suddenly gave me a settings window on start though I have been starting/closing lmms the whole day without no problem. It was most likely because of an empty .lmmsrc.xml .

lmms suddenly gave me a settings window

Thats so odd. This was posted a few says ago
https://lmms.io/forum/viewtopic.php?f=7&t=33856

Was yours on linux too?
My thoughts on his issues was mostly aimed at rights, that can be a pain in linux, or maybe some hardware issue, but then you have kind of similar thing..
A bug? @zonkmachine

@musikBear No, that's a different issue and probably not a bug.

Was this page helpful?
0 / 5 - 0 ratings