VST Automation: crash prevention

Fixed destuctors for various types of VST automation panel removal.

Automated signals correct disconection on panel removal.

When you load new VST plugin in the place of old one, while automation
is already connected and active there, this should not result in LMMS crash
or reuse of that old automation connections and automation window destructor
should not leave zombie VST plugins on application exit.

Signed-off-by: Tobias Doerffel <tobias.doerffel@gmail.com>
This commit is contained in:
Mike Choi
2013-01-03 19:28:47 +01:00
committed by Tobias Doerffel
parent 3cc01560be
commit c2e9918c8a
4 changed files with 151 additions and 31 deletions

View File

@@ -117,13 +117,14 @@ void vestigeInstrument::loadSettings( const QDomElement & _this )
m_plugin->loadSettings( _this );
const QMap<QString, QString> & dump = m_plugin->parameterDump();
int paramCount = (dump).size();
paramCount = dump.size();
char paramStr[35];
vstKnobs = new knob *[paramCount];
knobFModel = new FloatModel *[paramCount];
vstKnobs = new knob *[ paramCount ];
knobFModel = new FloatModel *[ paramCount ];
QStringList list1;
QWidget * widget = new QWidget();
for (int i = 0; i < paramCount; i++) {
for( int i = 0; i < paramCount; i++ )
{
sprintf( paramStr, "param%d", i);
list1 = dump[paramStr].split(":");
@@ -167,9 +168,10 @@ void vestigeInstrument::saveSettings( QDomDocument & _doc, QDomElement & _this )
m_plugin->saveSettings( _doc, _this );
if (knobFModel != NULL) {
const QMap<QString, QString> & dump = m_plugin->parameterDump();
int paramCount = (dump).size();
paramCount = dump.size();
char paramStr[35];
for (int i = 0; i < paramCount; i++) {
for( int i = 0; i < paramCount; i++ )
{
if (knobFModel[i]->isAutomated() || knobFModel[i]->getControllerConnection()) {
sprintf( paramStr, "param%d", i);
knobFModel[i]->saveSettings( _doc, _this, paramStr );
@@ -223,7 +225,10 @@ void vestigeInstrument::loadFile( const QString & _file )
InstrumentTrack::tr( "Default preset" );
m_pluginMutex.unlock();
closePlugin();
if ( m_plugin != NULL )
{
closePlugin();
}
m_pluginDLL = _file;
textFloat * tf = textFloat::displayMessage(
@@ -308,6 +313,51 @@ bool vestigeInstrument::handleMidiEvent( const midiEvent & _me,
void vestigeInstrument::closePlugin( void )
{
// disconnect all signals
if( knobFModel != NULL )
{
for( int i = 0; i < paramCount; i++ )
{
delete knobFModel[ i ];
delete vstKnobs[ i ];
}
}
if( vstKnobs != NULL )
{
delete [] vstKnobs;
vstKnobs = NULL;
}
if( knobFModel != NULL )
{
delete [] knobFModel;
knobFModel = NULL;
}
if( m_scrollArea != NULL )
{
// delete m_scrollArea;
m_scrollArea = NULL;
}
if( m_subWindow != NULL )
{
m_subWindow->setAttribute( Qt::WA_DeleteOnClose );
m_subWindow->close();
if( m_subWindow != NULL )
{
delete m_subWindow;
}
m_subWindow = NULL;
}
if( p_subWindow != NULL )
{
p_subWindow = NULL;
}
m_pluginMutex.lock();
if( m_plugin )
{
@@ -832,23 +882,24 @@ manageVestigeInstrumentView::manageVestigeInstrumentView( Instrument * _instrume
l->addWidget( m_syncButton, 0, 0, 1, 2, Qt::AlignLeft );
const QMap<QString, QString> & dump = m_vi->m_plugin->parameterDump();
int paramCount = (dump).size();
m_vi->paramCount = dump.size();
bool isVstKnobs = true;
if (m_vi->vstKnobs == NULL) {
m_vi->vstKnobs = new knob *[paramCount];
m_vi->vstKnobs = new knob *[ m_vi->paramCount ];
isVstKnobs = false;
}
if (m_vi->knobFModel == NULL) {
m_vi->knobFModel = new FloatModel *[paramCount];
m_vi->knobFModel = new FloatModel *[ m_vi->paramCount ];
}
char paramStr[35];
QStringList list1;
if (isVstKnobs == false) {
for (int i = 0; i < paramCount; i++) {
for( int i = 0; i < m_vi->paramCount; i++ )
{
sprintf( paramStr, "param%d", i);
list1 = dump[paramStr].split(":");
@@ -865,15 +916,19 @@ manageVestigeInstrumentView::manageVestigeInstrumentView( Instrument * _instrume
}
int i = 0;
for (int lrow = 0+1; lrow < (int(paramCount / 10) + 1)+1; lrow++) {
for (int lcolumn = 0; lcolumn < 10; lcolumn++) {
if (i < paramCount)
for( int lrow = 1; lrow < ( int( m_vi->paramCount / 10 ) + 1 ) + 1; lrow++ )
{
for( int lcolumn = 0; lcolumn < 10; lcolumn++ )
{
if( i < m_vi->paramCount )
{
l->addWidget( m_vi->vstKnobs[i], lrow, lcolumn, Qt::AlignCenter );
}
i++;
}
}
l->setRowStretch( (int(paramCount / 10) + 1), 1 );
l->setRowStretch( ( int( m_vi->paramCount / 10) + 1), 1 );
l->setColumnStretch( 10, 1 );
widget->setLayout(l);
@@ -911,10 +966,25 @@ void manageVestigeInstrumentView::syncPlugin( void )
manageVestigeInstrumentView::~manageVestigeInstrumentView()
{
if( m_vi->knobFModel != NULL )
{
for( int i = 0; i < m_vi->paramCount; i++ )
{
delete m_vi->knobFModel[ i ];
delete m_vi->vstKnobs[ i ];
}
}
if (m_vi->vstKnobs != NULL) {
delete []m_vi->vstKnobs;
m_vi->vstKnobs = NULL;
}
if( m_vi->knobFModel != NULL )
{
delete [] m_vi->knobFModel;
m_vi->knobFModel = NULL;
}
if (m_vi->m_scrollArea != NULL) {
delete m_vi->m_scrollArea;
@@ -929,6 +999,8 @@ manageVestigeInstrumentView::~manageVestigeInstrumentView()
delete m_vi->m_subWindow;
m_vi->m_subWindow = NULL;
}
m_vi->p_subWindow = NULL;
}

View File

@@ -92,6 +92,7 @@ private:
knob ** vstKnobs;
FloatModel ** knobFModel;
QObject * p_subWindow;
int paramCount;
friend class VestigeInstrumentView;

View File

@@ -69,13 +69,14 @@ void VstEffectControls::loadSettings( const QDomElement & _this )
m_effect->m_plugin->loadSettings( _this );
const QMap<QString, QString> & dump = m_effect->m_plugin->parameterDump();
int paramCount = (dump).size();
paramCount = dump.size();
char paramStr[35];
vstKnobs = new knob *[paramCount];
knobFModel = new FloatModel *[paramCount];
vstKnobs = new knob *[ paramCount ];
knobFModel = new FloatModel *[ paramCount ];
QStringList list1;
QWidget * widget = new QWidget();
for (int i = 0; i < paramCount; i++) {
for( int i = 0; i < paramCount; i++ )
{
sprintf( paramStr, "param%d", i);
list1 = dump[paramStr].split(":");
@@ -120,13 +121,15 @@ void VstEffectControls::saveSettings( QDomDocument & _doc, QDomElement & _this )
m_effect->m_plugin->saveSettings( _doc, _this );
if (knobFModel != NULL) {
const QMap<QString, QString> & dump = m_effect->m_plugin->parameterDump();
int paramCount = (dump).size();
paramCount = dump.size();
char paramStr[35];
for (int i = 0; i < paramCount; i++)
for( int i = 0; i < paramCount; i++ )
{
if (knobFModel[i]->isAutomated() || knobFModel[i]->getControllerConnection()) {
sprintf( paramStr, "param%d", i);
knobFModel[i]->saveSettings( _doc, _this, paramStr );
}
}
}
}
m_effect->m_pluginMutex.unlock();
@@ -321,17 +324,17 @@ manageVSTEffectView::manageVSTEffectView( VstEffect * _eff, VstEffectControls *
l->addWidget( m_syncButton, 0, 0, 1, 2, Qt::AlignLeft );
const QMap<QString, QString> & dump = m_effect->m_plugin->parameterDump();
int paramCount = (dump).size();
m_vi->paramCount = dump.size();
bool isVstKnobs = true, isKnobFModel = true;
if (m_vi->vstKnobs == NULL) {
m_vi->vstKnobs = new knob *[paramCount];
m_vi->vstKnobs = new knob *[ m_vi->paramCount ];
isVstKnobs = false;
}
if (m_vi->knobFModel == NULL) {
m_vi->knobFModel = new FloatModel *[paramCount];
m_vi->knobFModel = new FloatModel *[ m_vi->paramCount ];
isKnobFModel = false;
}
@@ -339,7 +342,8 @@ manageVSTEffectView::manageVSTEffectView( VstEffect * _eff, VstEffectControls *
QStringList list1;
if (isVstKnobs == false) {
for (int i = 0; i < paramCount; i++) {
for( int i = 0; i < m_vi->paramCount; i++ )
{
sprintf( paramStr, "param%d", i);
list1 = dump[paramStr].split(":");
@@ -356,15 +360,19 @@ manageVSTEffectView::manageVSTEffectView( VstEffect * _eff, VstEffectControls *
}
int i = 0;
for (int lrow = 0+1; lrow < (int(paramCount / 10) + 1)+1; lrow++) {
for (int lcolumn = 0; lcolumn < 10; lcolumn++) {
if (i < paramCount)
for( int lrow = 1; lrow < ( int( m_vi->paramCount / 10 ) + 1 ) + 1; lrow++ )
{
for( int lcolumn = 0; lcolumn < 10; lcolumn++ )
{
if( i < m_vi->paramCount )
{
l->addWidget( m_vi->vstKnobs[i], lrow, lcolumn, Qt::AlignCenter );
}
i++;
}
}
l->setRowStretch( (int(paramCount / 10) + 1), 1 );
l->setRowStretch( ( int( m_vi->paramCount / 10 ) + 1 ), 1 );
l->setColumnStretch( 10, 1 );
widget->setLayout(l);
@@ -418,8 +426,46 @@ void manageVSTEffectView::setParameter( void )
manageVSTEffectView::~manageVSTEffectView()
{
delete m_vi2->m_subWindow;
m_vi2->m_subWindow = NULL;
if( m_vi2->knobFModel != NULL )
{
for( int i = 0; i < m_vi2->paramCount; i++ )
{
delete m_vi2->knobFModel[ i ];
delete m_vi2->vstKnobs[ i ];
}
}
if( m_vi2->vstKnobs != NULL )
{
delete [] m_vi2->vstKnobs;
m_vi2->vstKnobs = NULL;
}
if( m_vi2->knobFModel != NULL )
{
delete [] m_vi2->knobFModel;
m_vi2->knobFModel = NULL;
}
if( m_vi2->m_scrollArea != NULL )
{
delete m_vi2->m_scrollArea;
m_vi2->m_scrollArea = NULL;
}
if( m_vi2->m_subWindow != NULL )
{
m_vi2->m_subWindow->setAttribute( Qt::WA_DeleteOnClose );
m_vi2->m_subWindow->close();
if( m_vi2->m_subWindow != NULL )
{
delete m_vi2->m_subWindow;
}
m_vi2->m_subWindow = NULL;
}
//delete m_vi2->m_subWindow;
//m_vi2->m_subWindow = NULL;
}

View File

@@ -88,6 +88,7 @@ private:
QScrollArea * m_scrollArea;
FloatModel ** knobFModel;
knob ** vstKnobs;
int paramCount;
QObject * ctrHandle;