Mixer: Fix export strip function.

This commit is contained in:
Jonathan Moore Liles 2021-01-20 17:22:51 -08:00
parent c83aa8ebd8
commit 181dd64689
2 changed files with 24 additions and 12 deletions

View File

@ -818,9 +818,8 @@ Mixer_Strip::export_strip ( const char *filename )
{
MESSAGE( "Exporting chain state" );
Loggable::snapshot_callback( &Mixer_Strip::snapshot, this );
Loggable::snapshot( filename );
return true;
}
return Loggable::snapshot( filename );
}
bool
Mixer_Strip::import_strip ( const char *filename )
@ -893,9 +892,12 @@ Mixer_Strip::menu_cb ( const Fl_Menu_ *m )
free( suggested_name );
if ( s )
export_strip( s );
fl_message( "Strip exported." );
{
if ( export_strip( s ) )
fl_message( "Strip exported." );
else
fl_alert("Failed to export strip");
}
}
else if ( ! strcmp( picked, "/Remove" ) )
{

View File

@ -590,20 +590,30 @@ Loggable::snapshot ( const char *name )
{
FILE *fp;
char *tmpname;
char *tmp = NULL;
{
const char *filename = basename(name);
char *dir = (char*)malloc( (strlen(name) - strlen(filename)) + 1 );
strncpy( dir, name, strlen(name) - strlen(filename) );
asprintf( &tmp, "%s#%s", dir, filename );
free(dir);
}
asprintf( &tmpname, ".#%s", name );
if ( ! ( fp = fopen( tmpname, "w" ) ))
if ( ! ( fp = fopen( tmp, "w" ) ))
{
DWARNING( "Could not open file for writing: %s", tmp );
return false;
}
bool r = snapshot( fp );
fclose( fp );
rename( tmpname, name );
rename( tmp, name );
free(tmpname);
free(tmp);
return r;
}