Fixes removing controller in controller rack bug
This commit is contained in:
@@ -33,7 +33,8 @@
|
||||
#include "JournallingObject.h"
|
||||
|
||||
class ControllerDialog;
|
||||
class Controller;
|
||||
class Controller;
|
||||
class ControllerConnection;
|
||||
|
||||
typedef QVector<Controller *> ControllerVector;
|
||||
|
||||
@@ -118,6 +119,11 @@ public:
|
||||
static void triggerFrameCounter();
|
||||
static void resetFrameCounter();
|
||||
|
||||
//Accepts a ControllerConnection * as it may be used in the future.
|
||||
void addConnection( ControllerConnection * );
|
||||
void removeConnection( ControllerConnection * );
|
||||
int connectionCount() const;
|
||||
|
||||
|
||||
public slots:
|
||||
virtual ControllerDialog * createDialog( QWidget * _parent );
|
||||
@@ -136,6 +142,7 @@ protected:
|
||||
|
||||
float m_currentValue;
|
||||
bool m_sampleExact;
|
||||
int m_connectionCount;
|
||||
|
||||
QString m_name;
|
||||
ControllerTypes m_type;
|
||||
|
||||
@@ -152,6 +152,11 @@ public:
|
||||
return m_key;
|
||||
}
|
||||
|
||||
EffectChain * getEffectChain() const
|
||||
{
|
||||
return m_parent;
|
||||
}
|
||||
|
||||
virtual EffectControls * controls() = 0;
|
||||
|
||||
static Effect * instantiate( const QString & _plugin_name,
|
||||
@@ -189,6 +194,7 @@ protected:
|
||||
|
||||
|
||||
private:
|
||||
EffectChain * m_parent;
|
||||
void resample( int _i, const sampleFrame * _src_buf,
|
||||
sample_rate_t _src_sr,
|
||||
sampleFrame * _dst_buf, sample_rate_t _dst_sr,
|
||||
|
||||
@@ -33,10 +33,10 @@ class PeakControllerEffect : public Effect
|
||||
{
|
||||
public:
|
||||
PeakControllerEffect( Model * parent,
|
||||
const Descriptor::SubPluginFeatures::Key * _key );
|
||||
const Descriptor::SubPluginFeatures::Key * _key );
|
||||
virtual ~PeakControllerEffect();
|
||||
virtual bool processAudioBuffer( sampleFrame * _buf,
|
||||
const fpp_t _frames );
|
||||
const fpp_t _frames );
|
||||
|
||||
virtual EffectControls * controls()
|
||||
{
|
||||
|
||||
@@ -49,6 +49,7 @@ Controller::Controller( ControllerTypes _type, Model * _parent,
|
||||
const QString & _display_name ) :
|
||||
Model( _parent, _display_name ),
|
||||
JournallingObject(),
|
||||
m_connectionCount( 0 ),
|
||||
m_type( _type )
|
||||
{
|
||||
if( _type != DummyController && _type != MidiController )
|
||||
@@ -277,6 +278,32 @@ ControllerDialog * Controller::createDialog( QWidget * _parent )
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void Controller::addConnection( ControllerConnection * )
|
||||
{
|
||||
m_connectionCount++;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void Controller::removeConnection( ControllerConnection * )
|
||||
{
|
||||
m_connectionCount--;
|
||||
Q_ASSERT( m_connectionCount >= 0 );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
int Controller::connectionCount() const{
|
||||
return m_connectionCount;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
#include "moc_Controller.cxx"
|
||||
|
||||
|
||||
|
||||
@@ -40,6 +40,7 @@ ControllerConnectionVector ControllerConnection::s_connections;
|
||||
|
||||
|
||||
ControllerConnection::ControllerConnection( Controller * _controller ) :
|
||||
m_controller( NULL ),
|
||||
m_controllerId( -1 ),
|
||||
m_ownsController( false )
|
||||
{
|
||||
@@ -71,6 +72,10 @@ ControllerConnection::ControllerConnection( int _controllerId ) :
|
||||
|
||||
ControllerConnection::~ControllerConnection()
|
||||
{
|
||||
if( m_controller && m_controller->type() != Controller::DummyController )
|
||||
{
|
||||
m_controller->removeConnection( this );
|
||||
}
|
||||
s_connections.remove( s_connections.indexOf( this ) );
|
||||
if( m_ownsController )
|
||||
{
|
||||
@@ -93,6 +98,12 @@ void ControllerConnection::setController( Controller * _controller )
|
||||
if( m_ownsController && m_controller )
|
||||
{
|
||||
delete m_controller;
|
||||
m_controller = NULL;
|
||||
}
|
||||
|
||||
if( m_controller && m_controller->type() != Controller::DummyController )
|
||||
{
|
||||
m_controller->removeConnection( this );
|
||||
}
|
||||
|
||||
if( !_controller )
|
||||
@@ -107,6 +118,7 @@ void ControllerConnection::setController( Controller * _controller )
|
||||
|
||||
if( _controller->type() != Controller::DummyController )
|
||||
{
|
||||
_controller->addConnection( this );
|
||||
QObject::connect( _controller, SIGNAL( valueChanged() ),
|
||||
this, SIGNAL( valueChanged() ) );
|
||||
}
|
||||
|
||||
@@ -39,6 +39,7 @@ Effect::Effect( const Plugin::Descriptor * _desc,
|
||||
Model * _parent,
|
||||
const Descriptor::SubPluginFeatures::Key * _key ) :
|
||||
Plugin( _desc, _parent ),
|
||||
m_parent( NULL ),
|
||||
m_key( _key ? *_key : Descriptor::SubPluginFeatures::Key() ),
|
||||
m_processors( 1 ),
|
||||
m_okay( true ),
|
||||
@@ -117,7 +118,9 @@ Effect * Effect::instantiate( const QString & _plugin_name,
|
||||
if( dynamic_cast<Effect *>( p ) != NULL )
|
||||
{
|
||||
// everything ok, so return pointer
|
||||
return dynamic_cast<Effect *>( p );
|
||||
Effect * effect = dynamic_cast<Effect *>( p );
|
||||
effect->m_parent = dynamic_cast<EffectChain *>(_parent);
|
||||
return effect;
|
||||
}
|
||||
|
||||
// not quite... so delete plugin and return dummy effect
|
||||
|
||||
@@ -131,6 +131,8 @@ void EffectChain::removeEffect( Effect * _effect )
|
||||
engine::mixer()->lock();
|
||||
m_effects.erase( qFind( m_effects.begin(), m_effects.end(), _effect ) );
|
||||
engine::mixer()->unlock();
|
||||
|
||||
emit dataChanged();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -34,6 +34,7 @@
|
||||
#include "engine.h"
|
||||
#include "Mixer.h"
|
||||
#include "PeakController.h"
|
||||
#include "EffectChain.h"
|
||||
#include "ControllerDialog.h"
|
||||
#include "plugins/peak_controller_effect/peak_controller_effect.h"
|
||||
|
||||
@@ -57,7 +58,10 @@ PeakController::PeakController( Model * _parent,
|
||||
|
||||
PeakController::~PeakController()
|
||||
{
|
||||
// disconnects
|
||||
if( m_peakEffect != NULL && m_peakEffect->getEffectChain() != NULL )
|
||||
{
|
||||
m_peakEffect->getEffectChain()->removeEffect( m_peakEffect );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -76,7 +80,7 @@ float PeakController::value( int _offset )
|
||||
void PeakController::handleDestroyedEffect( )
|
||||
{
|
||||
// possible race condition...
|
||||
printf("disconnecting effect\n");
|
||||
//printf("disconnecting effect\n");
|
||||
disconnect( m_peakEffect );
|
||||
m_peakEffect = NULL;
|
||||
//deleteLater();
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
#include <QtGui/QScrollArea>
|
||||
#include <QtGui/QVBoxLayout>
|
||||
#include <QtGui/QMdiArea>
|
||||
#include <QMessageBox>
|
||||
|
||||
#include "song.h"
|
||||
#include "embed.h"
|
||||
@@ -117,8 +118,23 @@ void ControllerRackView::loadSettings( const QDomElement & _this )
|
||||
|
||||
void ControllerRackView::deleteController( ControllerView * _view )
|
||||
{
|
||||
|
||||
Controller * c = _view->getController();
|
||||
|
||||
int connectionCount = c->connectionCount();
|
||||
if( connectionCount > 0 )
|
||||
{
|
||||
QMessageBox msgBox;
|
||||
msgBox.setIcon( QMessageBox::Question );
|
||||
msgBox.setText( tr("Confirm delete? There are existing connection(s) "
|
||||
"associted with this controller. There is no way to undo.") );
|
||||
msgBox.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel);
|
||||
if( msgBox.exec() != QMessageBox::Ok )
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
m_controllerViews.erase( qFind( m_controllerViews.begin(),
|
||||
m_controllerViews.end(), _view ) );
|
||||
delete _view;
|
||||
|
||||
Reference in New Issue
Block a user