-
-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Don't allow invalid project files! #2523
Conversation
Looks good. 👍 I'll leave time for comments. One thought was the posiblity of loading a non-mmp or non-mmpz file, but |
Yes, I was going to ask about it. |
In the last version it still tests for an empty |
2e8aaaa
to
469117d
Compare
An mpt file? |
Any valid LMMS project file that happens to be named differently from what's expected? If I explicitly tell LMMS to load a file called "myproject.mmpx" or whatever, I expect it to at least try and not reject the file until it's at least opened the file and tried parsing it. |
OK. Right now if you try and save a project file with another suffix than .mmp or .mmpz, it will stick a new suffix after the one you opted for. In your case with myproject.mmpx you will get myproject.mmpx.mmpz so on my Ubuntu/Mint I have to go back and change suffix manually and then myproject.mmpx will open as you expect it. Edit: Only files ending mmp/mmpz will show up in the file open dialogue so other valid projects will have to be loaded from the command line. |
469117d
to
9600c50
Compare
fileInfoImport.suffix().toLower() == "midi" || | ||
fileInfoImport.suffix().toLower() == "rmi" || | ||
fileInfoImport.suffix().toLower() == "flp" || | ||
fileInfoImport.suffix().toLower() == "h2song" ) ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm.... Every time I see a laundry list of file extensions I get worried that we're making more work for ourselves down the road. 😄 Perhaps related to this PR, perhaps not.... can we start managing our extension in a centralized place? We should be able to use #ifdef
's to enable/disable them globally based on what libraries/plugins cmake finds. We already do this in several other places already. Food for thought.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps related to this PR, perhaps not.... can we start managing our extension in a centralized place?
Related but it doesn't sound like something I can implement.
9600c50
to
4a3fca6
Compare
Conflicts resolved. |
4a3fca6
to
080119c
Compare
@zonkmachine is there any more work needed to be done here, or it could be tested and merged? |
Yes, mad sorry about the slow response here. Short on time. I'll look into it as soon as I possibly can. |
OK. Trying to finish this one now. |
94d106a
to
2bcda0e
Compare
} | ||
else if( !( fileInfoLoad.suffix().toLower() == "mmp" || | ||
fileInfoLoad.suffix().toLower() == "mmpz" || | ||
fileInfoLoad.suffix().toLower() == "mpt" ) ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Older projects use the xml
extension.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
Current fix is incomplete. Input file could be an empty file, the empty template, a broken project or a different XML file. I do not think these new checks are necessary. The check for empty projects on export should be enough. |
I mean checking the extension, if the input does not exists, etc. |
Right, back on this...
Hm, missed that. Poking around with it right now...
...Will open correctly.
A file that is empty or a broken project will be passed to LMMS who will fail to open it and report on it. It will then open an empty project with the title of the project you tried to open. |
fcdf23a
to
b437266
Compare
I mean that rendering those invalid projects (empty file, empty template, etc.) with |
Right. In the case of an empty file the latest commit proposed a fix and it's working. An empty template however, I think goes a bit beyond this PR. Shouldn't it rather be catched by the renderer? |
When exporting from the gui lmms ran TrackContainer::isEmpty() so I added this test in main.
|
else if( !( fileInfoLoad.suffix().toLower() == "mmp" || | ||
fileInfoLoad.suffix().toLower() == "mmpz" || | ||
fileInfoLoad.suffix().toLower() == "mpt" || | ||
fileInfoLoad.suffix().toLower() == "xml" ) ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Having one of these extensions is not required; this check should be removed. The Engine::getSong()->isEmpty()
check takes care of invalid projects.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK. I initially made these suffix tests because lmms opens in an unclean manner when you throw a file whatever at it. It will open a blank project with the title you just gave it. I think at least we should not set the project title when the project couldn't be opened.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It will open a blank project with the title you just gave it. I think at least we should not set the project title when the project couldn't be opened.
That's a regression from 1.1.3 which does this just fine...
9e0cccc
to
d06f253
Compare
{ | ||
fileCheck( fileToLoad ); | ||
} | ||
if( !fileToImport.isEmpty() ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
else if
Should I short this one out and give fileToLoad priority?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, fixed that...
d06f253
to
5e5c88a
Compare
5e5c88a
to
0039460
Compare
{ | ||
printf("The project %s is empty, aborting!\n", fileToLoad.toUtf8().constData() ); | ||
exit( EXIT_FAILURE ); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is exit() even a good way to terminate the application at this point?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You may omit exit()
and avoid the export, so an upgraded .lmmsrc.xml
can be written, but exit()
(or return
) is not a bad way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oK. I just skimmed past some comment on the net that exit() could be a problem with multi threaded applications. I'm happy with .lmmsrc.xml not being written so we keep failing loads from appearing in the recently opened projects list.
lmms used to load default.mmp on failing to load a project but this was broken in commit: 2c7036e#diff-1c0d925f7437a8e3a837c0a991b4cf34 I'll try and look into the original issue (Edit: #781) behind that PR Edit2: Fix for this in #3013 |
It's better to not inflate this PR. The regression in Song.cpp is not directly related to these fixes so I'll treat them separately. Rebased and squashed! 🚜 |
This request may be merged. |
🚜 |
* master: (213 commits) Update Pattern and AutomationPattern length (LMMS#3037) Refresh i18n strings Hint text update Drop notes with length zero (LMMS#3031) Background tweak Background Update Flanger Exclude .ts files from the Github linguist Redesign Multitap echo (LMMS#3008) Update i18n source strings Extended arpeggiator functions (LMMS#2130) Fix sample track playback in BB tracks (LMMS#3023) Sort plug-in embedded resources (LMMS#3014) Implement version major.minor.release-stage.build (LMMS#3011) Fix regressions on loading broken projects (LMMS#3013) Improved file input validation. (LMMS#2523) Fix sample track view in BB editor (LMMS#3002) Request change in model when dropping a track (LMMS#3000) Add LocklessAllocator and use it in LocklessList (LMMS#2998) Drop forceStep in AutomatableModel (LMMS#3010) ...
The renderer hangs bad if you give it something that isn't an LMMS project as argument.
This fix tests that the given file is really a file ( not a directory ). It also tests for a valid LMMS project suffix.
You can test specifically for if the argument is a directory and report accordingly but that would be over doing it a bit I think.
I finally moved the line
Engine::init( true );
to after the tests as it just felt like a better place.