Browse Source

Don't crash when song cannot be loaded via LASH.

Consider invalid song path given via command line a fatal error.
tags/non-sequencer-v1.9.4
Jonathan Moore Liles 17 years ago
parent
commit
72ae9470d3
4 changed files with 23 additions and 5 deletions
  1. +2
    -1
      lash.C
  2. +13
    -2
      main.C
  3. +7
    -1
      sequence.C
  4. +1
    -1
      smf.C

+ 2
- 1
lash.C View File

@@ -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 ) );



+ 13
- 2
main.C View File

@@ -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() )


+ 7
- 1
sequence.C View File

@@ -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();



+ 1
- 1
smf.C View File

@@ -64,7 +64,7 @@ smf::open ( const char *name, int mode )

_fp = fopen( _name, mode == smf::WRITE ? "w" : "r" );

return _fp > 0;
return _fp != NULL;
}

/*************************/


Loading…
Cancel
Save