From 6e4baf30a9246e61ea5f84ef7eff1f2dcdf8ec74 Mon Sep 17 00:00:00 2001 From: aj_genius Date: Fri, 30 Jan 2004 21:03:06 +0000 Subject: [PATCH] Partly rework Deleting Devices, seems to fix random(and sometimes not so random) crashes --- SpiralSound/Plugins/SpiralPlugin.C | 7 ++----- SpiralSynthModular.C | 22 ++++++++++++++-------- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/SpiralSound/Plugins/SpiralPlugin.C b/SpiralSound/Plugins/SpiralPlugin.C index 063d37d..e21166f 100644 --- a/SpiralSound/Plugins/SpiralPlugin.C +++ b/SpiralSound/Plugins/SpiralPlugin.C @@ -39,11 +39,8 @@ SpiralPlugin::SpiralPlugin() SpiralPlugin::~SpiralPlugin() { - for (int n=0; nsecond->m_DeviceGUI->Killed()) { PauseAudio(); - if (i->second->m_Device) - { - delete i->second->m_Device; - i->second->m_Device=NULL; - } + //Hide Device GUI FIRST if (i->second->m_DeviceGUI->GetPluginWindow()) { i->second->m_DeviceGUI->GetPluginWindow()->hide(); - //m_MainWindow->remove(i->second->m_DeviceGUI->GetPluginWindow()); } + //Clear and remove Device GUI from canvas i->second->m_DeviceGUI->Clear(); m_Canvas->RemoveDevice(i->second->m_DeviceGUI); - // deleted by Canvas::Remove()? seems to cause random crashes - //delete i->second->m_DeviceGUI; + + //Delete Device GUI - must delete here or sometimes plugin will randomly crash + delete i->second->m_DeviceGUI; + + //Delete Device Sometimes deleting audio before GUI causes an odd crash, so do it afterword + if (i->second->m_Device) + { + delete i->second->m_Device; + i->second->m_Device=NULL; + } + //Erase Device from DeviceWinMap m_DeviceWinMap.erase(i); + ResumeAudio(); break; }