Vst: Fix widget deletion

This commit is contained in:
Lukas W
2017-11-10 08:02:29 +01:00
parent 6fd38fee9f
commit a8311a7b49
4 changed files with 13 additions and 28 deletions

View File

@@ -55,7 +55,6 @@ Plugin::Descriptor PLUGIN_EXPORT vsteffect_plugin_descriptor =
VstEffect::VstEffect( Model * _parent,
const Descriptor::SubPluginFeatures::Key * _key ) :
Effect( &vsteffect_plugin_descriptor, _parent, _key ),
m_plugin( NULL ),
m_pluginMutex(),
m_key( *_key ),
m_vstControls( this )
@@ -73,7 +72,6 @@ VstEffect::VstEffect( Model * _parent,
VstEffect::~VstEffect()
{
closePlugin();
}
@@ -128,22 +126,20 @@ void VstEffect::openPlugin( const QString & _plugin )
VstPlugin::tr( "Loading plugin" ),
VstPlugin::tr( "Please wait while loading VST plugin..." ),
PLUGIN_NAME::getIconPixmap( "logo", 24, 24 ), 0 );
m_pluginMutex.lock();
m_plugin = new VstPlugin( _plugin );
QMutexLocker ml( &m_pluginMutex ); Q_UNUSED( ml );
m_plugin.reset(new VstPlugin( _plugin ));
if( m_plugin->failed() )
{
m_pluginMutex.unlock();
closePlugin();
m_plugin.reset(nullptr);
delete tf;
collectErrorForUI( VstPlugin::tr( "The VST plugin %1 could not be loaded." ).arg( _plugin ) );
return;
}
VstPlugin::connect( Engine::getSong(), SIGNAL( tempoChanged( bpm_t ) ), m_plugin, SLOT( setTempo( bpm_t ) ) );
VstPlugin::connect( Engine::getSong(), SIGNAL( tempoChanged( bpm_t ) ), m_plugin.data(), SLOT( setTempo( bpm_t ) ) );
m_plugin->setTempo( Engine::getSong()->getTempo() );
m_pluginMutex.unlock();
delete tf;
m_key.attributes["file"] = _plugin;
@@ -151,21 +147,6 @@ void VstEffect::openPlugin( const QString & _plugin )
void VstEffect::closePlugin()
{
m_pluginMutex.lock();
if( m_plugin && m_plugin->pluginWidget() != NULL )
{
delete m_plugin->pluginWidget();
}
delete m_plugin;
m_plugin = NULL;
m_pluginMutex.unlock();
}
extern "C"
{

View File

@@ -25,13 +25,14 @@
#ifndef _VST_EFFECT_H
#define _VST_EFFECT_H
#include <QMutex>
#include <QtCore/QMutex>
#include <QtCore/QSharedPointer>
#include "Effect.h"
#include "VstPlugin.h"
#include "VstEffectControlDialog.h"
#include "VstEffectControls.h"
class VstPlugin;
class VstEffect : public Effect
{
@@ -58,7 +59,7 @@ private:
void openPlugin( const QString & _plugin );
void closePlugin();
VstPlugin * m_plugin;
QSharedPointer<VstPlugin> m_plugin;
QMutex m_pluginMutex;
EffectKey m_key;

View File

@@ -31,6 +31,7 @@
#include <QObject>
#include <QPainter>
#include <QLabel>
#include <QSharedPointer>
class VstEffectControls;
@@ -59,7 +60,7 @@ private:
PixmapButton * m_managePluginButton;
PixmapButton * m_savePresetButton;
VstPlugin * m_plugin;
QSharedPointer<VstPlugin> m_plugin;
QLabel * tbLabel;

View File

@@ -130,6 +130,8 @@ VstPlugin::VstPlugin( const QString & _plugin ) :
VstPlugin::~VstPlugin()
{
delete m_pluginSubWindow;
delete m_pluginWidget;
}