Merge pull request #200 from wongcc966422/issue28
Fixes removing controller in controller rack bug
This commit is contained in:
@@ -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->effectChain() != NULL )
|
||||
{
|
||||
m_peakEffect->effectChain()->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,24 @@ 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.setWindowTitle( tr("Confirm Delete") );
|
||||
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