-
-
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -176,6 +176,27 @@ void printHelp() | |
|
||
|
||
|
||
void fileCheck( QString &file ) | ||
{ | ||
QFileInfo fileToCheck( file ); | ||
|
||
if( !fileToCheck.size() ) | ||
{ | ||
printf( "The file %s does not have any content.\n", | ||
file.toUtf8().constData() ); | ||
exit( EXIT_FAILURE ); | ||
} | ||
else if( fileToCheck.isDir() ) | ||
{ | ||
printf( "%s is a directory.\n", | ||
file.toUtf8().constData() ); | ||
exit( EXIT_FAILURE ); | ||
} | ||
} | ||
|
||
|
||
|
||
|
||
int main( int argc, char * * argv ) | ||
{ | ||
// initialize memory managers | ||
|
@@ -567,6 +588,15 @@ int main( int argc, char * * argv ) | |
} | ||
} | ||
|
||
// Test file argument before continuing | ||
if( !fileToLoad.isEmpty() ) | ||
{ | ||
fileCheck( fileToLoad ); | ||
} | ||
else if( !fileToImport.isEmpty() ) | ||
{ | ||
fileCheck( fileToImport ); | ||
} | ||
|
||
ConfigManager::inst()->loadConfigFile(configFile); | ||
|
||
|
@@ -636,15 +666,13 @@ int main( int argc, char * * argv ) | |
Engine::init( true ); | ||
destroyEngine = true; | ||
|
||
QFileInfo fileInfo( fileToLoad ); | ||
if ( !fileInfo.exists() ) | ||
{ | ||
printf("The file %s does not exist!\n", fileToLoad.toStdString().c_str()); | ||
exit( 1 ); | ||
} | ||
|
||
printf( "Loading project...\n" ); | ||
Engine::getSong()->loadProject( fileToLoad ); | ||
if( Engine::getSong()->isEmpty() ) | ||
{ | ||
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 commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. You may omit There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
printf( "Done\n" ); | ||
|
||
Engine::getSong()->setExportLoop( renderLoop ); | ||
|
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.
Shouldn't this be the other way around? Shouldn't we only instantiate
fileInfoLoad
if the QString isn't null or empty? This would also remove the need for setting an empty QString above.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.
The above code comment from April still remains unanswered and you have a commented line that should be removed prior to merging.
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.
No, I don't think so, but this part is essentially the same as before. I just moved it and expanded on the functionality.
comment removed
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.
fileInfoLoad
should be instantiated in theif( !fileToLoad.isEmpty() )
block;fileInfoImport
, in theif( !fileToImport.isEmpty() )
one.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 updated the according to Javiers suggestions.