Mixer: Destroy instances of Controller_Module when the connected modules are removed.

This commit is contained in:
Jonathan Moore Liles 2012-02-19 23:45:15 -08:00
parent e9804033ab
commit 31f0d6b311
1 changed files with 12 additions and 2 deletions

View File

@ -71,7 +71,6 @@ Module::Module ( ) : Fl_Group( 0, 0, 50, 50, "Unnamed" )
Module::~Module ( ) Module::~Module ( )
{ {
if ( _editor ) if ( _editor )
{ {
delete _editor; delete _editor;
@ -84,7 +83,15 @@ Module::~Module ( )
audio_output[i].disconnect(); audio_output[i].disconnect();
for ( unsigned int i = 0; i < control_input.size(); ++i ) for ( unsigned int i = 0; i < control_input.size(); ++i )
{ {
control_input[i].disconnect(); /* destroy connected Controller_Module */
if ( control_input[i].connected() )
{
Module *o = (Module*)control_input[i].connected_port()->module();
control_input[i].disconnect();
delete o;
}
control_input[i].destroy_osc_port(); control_input[i].destroy_osc_port();
} }
for ( unsigned int i = 0; i < control_output.size(); ++i ) for ( unsigned int i = 0; i < control_output.size(); ++i )
@ -95,6 +102,9 @@ Module::~Module ( )
control_input.clear(); control_input.clear();
control_output.clear(); control_output.clear();
if ( parent() )
parent()->remove( this );
} }