Don't crash when song cannot be loaded via LASH.
Consider invalid song path given via command line a fatal error.
This commit is contained in:
parent
8ae4e4f40c
commit
72ae9470d3
3
lash.C
3
lash.C
|
@ -85,7 +85,8 @@ Lash::process ( void )
|
|||
{
|
||||
MESSAGE( "LASH wants us to load \"%s\"", name );
|
||||
|
||||
load_song( name );
|
||||
if ( ! load_song( name ) )
|
||||
/* FIXME: should we tell lash that we couldn't load the song? */;
|
||||
|
||||
lash_send_event( _client, lash_event_new_with_type( LASH_Restore_File ) );
|
||||
|
||||
|
|
15
main.C
15
main.C
|
@ -100,13 +100,16 @@ load_song ( const char *name )
|
|||
{
|
||||
MESSAGE( "loading song \"%s\"", name );
|
||||
|
||||
Grid *pattern_grid = pattern_c->grid();
|
||||
Grid *phrase_grid = phrase_c->grid();
|
||||
|
||||
pattern_c->grid( NULL );
|
||||
phrase_c->grid( NULL );
|
||||
|
||||
if ( ! playlist->load( name ) )
|
||||
{
|
||||
WARNING( "failed to load song file" );
|
||||
return false;
|
||||
goto failed;
|
||||
}
|
||||
|
||||
pattern_c->grid( pattern::pattern_by_number( 1 ) );
|
||||
|
@ -117,6 +120,13 @@ load_song ( const char *name )
|
|||
song.dirty( false );
|
||||
|
||||
return true;
|
||||
|
||||
failed:
|
||||
|
||||
pattern_c->grid( pattern_grid );
|
||||
phrase_c->grid( phrase_grid );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool
|
||||
|
@ -163,7 +173,8 @@ main ( int argc, char **argv )
|
|||
if ( argc > 1 )
|
||||
{
|
||||
/* maybe a filename on the commandline */
|
||||
load_song( argv[1] );
|
||||
if ( ! load_song( argv[ 1 ] ) )
|
||||
ASSERTION( "Could not load song \"%s\" specified on command line", argv[ 1 ] );
|
||||
}
|
||||
|
||||
if ( ! midi_init() )
|
||||
|
|
|
@ -24,6 +24,8 @@
|
|||
|
||||
#include "non.H"
|
||||
|
||||
#include <errno.h>
|
||||
|
||||
/* #include <string> */
|
||||
|
||||
/* using std::string; */
|
||||
|
@ -281,7 +283,11 @@ sequence::load ( const char *name )
|
|||
{
|
||||
smf f;
|
||||
|
||||
f.open( name, smf::READ );
|
||||
if ( ! f.open( name, smf::READ ) )
|
||||
{
|
||||
WARNING( "error opening file: %s", strerror( errno ) );
|
||||
return false;
|
||||
}
|
||||
|
||||
f.read_header();
|
||||
|
||||
|
|
Loading…
Reference in New Issue