Mixer: Fix segfault in module paste.

pull/3/head
Jonathan Moore Liles 2012-07-21 16:31:55 -07:00
parent 15e095092c
commit 3a999ecc86
4 changed files with 46 additions and 14 deletions

View File

@ -190,8 +190,15 @@ Module::paste_before ( void )
{
Module *m = _copied_module_empty;
m->chain( chain() );
Log_Entry le( _copied_module_settings );
le.remove( ":chain" );
char *print = le.print();
DMESSAGE( "Pasting settings: %s", print );
free( print );
m->set( le );
if ( ! chain()->insert( this, m ) )
@ -203,7 +210,7 @@ Module::paste_before ( void )
_copied_module_settings = NULL;
_copied_module_empty = NULL;
/* set up for another copy */
/* set up for another paste */
m->copy();
}
@ -429,6 +436,26 @@ Module::set ( Log_Entry &e )
void
Module::chain ( Chain *v )
{
if ( _chain != v )
{
DMESSAGE( "Adding module %s in to chain %s", label(), v ? v->name() : "NULL" );
_chain = v;
for ( int i = 0; i < ncontrol_inputs(); ++i )
{
control_input[i].update_osc_port();
}
}
else
{
DMESSAGE( "Module %s already belongs to chain %s", label(), v ? v->name() : "NULL" );
}
}
/* return a string serializing this module's parameter settings. The
format is 1.0:2.0:... Where 1.0 is the value of the first control
input, 2.0 is the value of the second control input etc.

View File

@ -373,18 +373,7 @@ public:
}
Chain *chain ( void ) const { return _chain; }
void chain ( Chain * v )
{
if ( _chain != v )
{
_chain = v;
for ( int i = 0; i < ncontrol_inputs(); ++i )
{
control_input[i].update_osc_port();
}
}
}
void chain ( Chain * v );
char *get_parameters ( void ) const;
void set_parameters ( const char * );

View File

@ -280,6 +280,19 @@ Log_Entry::get ( int n, const char **name, const char **value ) const
}
void
Log_Entry::remove ( const char *name )
{
for ( int i = 0; i < _i; i++ )
{
if ( !strcmp( _sa[ i ], name ) )
{
free( _sa[i] );
_sa[i] = NULL;
}
}
}
char **
Log_Entry::sa ( void )
{

View File

@ -88,6 +88,9 @@ public:
/* _sa.push( p ); \ */
/* } \ */
void remove ( const char *s );
ADD( int, "%d", v );
ADD( nframes_t, "%lu", (unsigned long)v );
ADD( unsigned long, "%lu", v );