mirror of
https://github.com/LMMS/lmms.git
synced 2026-05-18 19:55:00 -04:00
Prevent cycles in controller connections.
git-svn-id: https://lmms.svn.sf.net/svnroot/lmms/trunk/lmms@1440 0778d3d1-df1d-0410-868b-ea421aaaa00d
This commit is contained in:
@@ -1,3 +1,11 @@
|
||||
2008-08-18 Tobias Doerffel <tobydox/at/users/dot/sourceforge/dot/net>
|
||||
|
||||
* include/controller.h:
|
||||
* src/core/controller.cpp:
|
||||
* src/gui/automatable_model_view.cpp:
|
||||
* src/gui/controller_connection_dialog.cpp:
|
||||
Detect loops before allowing controller-connection
|
||||
|
||||
2008-08-07 Tobias Doerffel <tobydox/at/users/dot/sourceforge/dot/net>
|
||||
|
||||
* CMakeLists.txt:
|
||||
|
||||
@@ -114,6 +114,8 @@ public slots:
|
||||
m_name = _new_name;
|
||||
}
|
||||
|
||||
bool hasModel( const model * m );
|
||||
|
||||
|
||||
protected:
|
||||
// The internal per-controller get-value function
|
||||
|
||||
@@ -190,6 +190,36 @@ controller * controller::create( const QDomElement & _this, model * _parent )
|
||||
|
||||
|
||||
|
||||
bool controller::hasModel( const model * m )
|
||||
{
|
||||
QObjectList chldren = children();
|
||||
for( int i = 0; i < chldren.size(); ++i )
|
||||
{
|
||||
QObject * c = chldren.at(i);
|
||||
automatableModel * am = qobject_cast<automatableModel*>(c);
|
||||
if( am != NULL )
|
||||
{
|
||||
if( am == m )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
controllerConnection * cc = am->getControllerConnection();
|
||||
if( cc != NULL )
|
||||
{
|
||||
if( cc->getController()->hasModel( m ) )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void controller::saveSettings( QDomDocument & _doc, QDomElement & _this )
|
||||
{
|
||||
_this.setAttribute( "type", type() );
|
||||
|
||||
@@ -25,7 +25,6 @@
|
||||
|
||||
#include <QtGui/QMenu>
|
||||
#include <QtGui/QMouseEvent>
|
||||
|
||||
#include "automatable_model_view.h"
|
||||
#include "automation_pattern.h"
|
||||
#include "controller_connection_dialog.h"
|
||||
@@ -183,32 +182,33 @@ void automatableModelViewSlots::execConnectionDialog( void )
|
||||
controllerConnectionDialog * d = new controllerConnectionDialog(
|
||||
(QWidget*)engine::getMainWindow(), m );
|
||||
|
||||
d->exec();
|
||||
|
||||
// Actually chose something
|
||||
if (d->chosenController() != NULL )
|
||||
if( d->exec() == 1)
|
||||
{
|
||||
// Update
|
||||
if( m->getControllerConnection() )
|
||||
// Actually chose something
|
||||
if (d->chosenController() != NULL )
|
||||
{
|
||||
m->getControllerConnection()->
|
||||
setController( d->chosenController() );
|
||||
// Update
|
||||
if( m->getControllerConnection() )
|
||||
{
|
||||
m->getControllerConnection()->
|
||||
setController( d->chosenController() );
|
||||
}
|
||||
// New
|
||||
else
|
||||
{
|
||||
controllerConnection * cc =
|
||||
new controllerConnection( d->chosenController() );
|
||||
m->setControllerConnection( cc );
|
||||
//cc->setTargetName( m->displayName() );
|
||||
|
||||
}
|
||||
}
|
||||
// New
|
||||
// no controller, so delete existing connection
|
||||
else
|
||||
{
|
||||
controllerConnection * cc =
|
||||
new controllerConnection( d->chosenController() );
|
||||
m->setControllerConnection( cc );
|
||||
//cc->setTargetName( m->displayName() );
|
||||
|
||||
removeConnection();
|
||||
}
|
||||
}
|
||||
// no controller, so delete existing connection
|
||||
else
|
||||
{
|
||||
removeConnection();
|
||||
}
|
||||
|
||||
delete d;
|
||||
}
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
#include <QtGui/QLineEdit>
|
||||
#include <QtGui/QPushButton>
|
||||
#include <QtGui/QScrollArea>
|
||||
#include <QMessageBox>
|
||||
|
||||
#include "controller_connection_dialog.h"
|
||||
#include "controller_connection.h"
|
||||
@@ -327,7 +328,15 @@ void controllerConnectionDialog::selectController( void )
|
||||
m_controller = engine::getSong()->controllers().at(
|
||||
m_userController->model()->value() );
|
||||
}
|
||||
|
||||
if( m_controller->hasModel( m_targetModel ) )
|
||||
{
|
||||
QMessageBox::warning(this, tr("LMMS"), tr("Cycle Detected."));
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
accept();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user