From bbd49089a124ec54a20dee0b138b92a26a93f8e1 Mon Sep 17 00:00:00 2001 From: Jonathan Moore Liles Date: Fri, 22 Feb 2008 18:37:46 -0600 Subject: [PATCH] Oops. Fix regression in instrument loader resulting in a confusing error message. --- instrument.C | 33 +++++++++++++++++++++------------ 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/instrument.C b/instrument.C index 0c7f66e..9b84d74 100644 --- a/instrument.C +++ b/instrument.C @@ -39,19 +39,19 @@ using std::list; using std::string; /****** - Instrument definition file format is thus: + Instrument definition file format is thus: - "Name", n, v + "Name", n, v - Where /n/ is a note number from 0 to 127 and /v/ is a percentage of - volume. + Where /n/ is a note number from 0 to 127 and /v/ is a percentage of + volume. - When a system installed instrument definition is modified, the - modified version is saved in the user's $HOME. Therefore, when - loading instruments, user defined instruments always hide system - defined instruments of the same name. + When a system installed instrument definition is modified, the + modified version is saved in the user's $HOME. Therefore, when + loading instruments, user defined instruments always hide system + defined instruments of the same name. - */ +*/ list Instrument::instruments; @@ -114,7 +114,7 @@ Instrument::velocity ( int n, int v ) } /** Translate event, should only be passed NOTE ON/OFF events, returns - true if note is valid for this mapping */ + true if note is valid for this mapping */ bool Instrument::translate ( midievent *e ) const { @@ -290,12 +290,21 @@ Instrument::listing ( void ) list *sys = get_listing( SYSTEM_PATH INSTRUMENT_DIR ); list *usr = get_listing( config.user_config_dir ); - usr->merge( *sys ); + if ( ! ( usr || sys ) ) + return NULL; + + if ( sys && usr ) + usr->merge( *sys ); + else + if ( sys && ! usr ) + usr = sys; + usr->unique(); usr->sort(); - delete sys; + if ( sys ) + delete sys; char **sa = (char**)malloc( (usr->size() + 1) * sizeof( char * ) );