Consider invalid song path given via command line a fatal error.tags/non-sequencer-v1.9.4
@@ -85,7 +85,8 @@ Lash::process ( void ) | |||||
{ | { | ||||
MESSAGE( "LASH wants us to load \"%s\"", name ); | 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 ) ); | lash_send_event( _client, lash_event_new_with_type( LASH_Restore_File ) ); | ||||
@@ -100,13 +100,16 @@ load_song ( const char *name ) | |||||
{ | { | ||||
MESSAGE( "loading song \"%s\"", name ); | MESSAGE( "loading song \"%s\"", name ); | ||||
Grid *pattern_grid = pattern_c->grid(); | |||||
Grid *phrase_grid = phrase_c->grid(); | |||||
pattern_c->grid( NULL ); | pattern_c->grid( NULL ); | ||||
phrase_c->grid( NULL ); | phrase_c->grid( NULL ); | ||||
if ( ! playlist->load( name ) ) | if ( ! playlist->load( name ) ) | ||||
{ | { | ||||
WARNING( "failed to load song file" ); | WARNING( "failed to load song file" ); | ||||
return false; | |||||
goto failed; | |||||
} | } | ||||
pattern_c->grid( pattern::pattern_by_number( 1 ) ); | pattern_c->grid( pattern::pattern_by_number( 1 ) ); | ||||
@@ -117,6 +120,13 @@ load_song ( const char *name ) | |||||
song.dirty( false ); | song.dirty( false ); | ||||
return true; | return true; | ||||
failed: | |||||
pattern_c->grid( pattern_grid ); | |||||
phrase_c->grid( phrase_grid ); | |||||
return false; | |||||
} | } | ||||
bool | bool | ||||
@@ -163,7 +173,8 @@ main ( int argc, char **argv ) | |||||
if ( argc > 1 ) | if ( argc > 1 ) | ||||
{ | { | ||||
/* maybe a filename on the commandline */ | /* 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() ) | if ( ! midi_init() ) | ||||
@@ -24,6 +24,8 @@ | |||||
#include "non.H" | #include "non.H" | ||||
#include <errno.h> | |||||
/* #include <string> */ | /* #include <string> */ | ||||
/* using std::string; */ | /* using std::string; */ | ||||
@@ -281,7 +283,11 @@ sequence::load ( const char *name ) | |||||
{ | { | ||||
smf f; | 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(); | f.read_header(); | ||||
@@ -64,7 +64,7 @@ smf::open ( const char *name, int mode ) | |||||
_fp = fopen( _name, mode == smf::WRITE ? "w" : "r" ); | _fp = fopen( _name, mode == smf::WRITE ? "w" : "r" ); | ||||
return _fp > 0; | |||||
return _fp != NULL; | |||||
} | } | ||||
/*************************/ | /*************************/ | ||||