Fix crash when loading project with missing peak controller effect (#4391)
* Fix crash when loading project with missing peak controller effect * Don't load/save dummy controller connections
This commit is contained in:
@@ -110,7 +110,8 @@ void AutomatableModel::saveSettings( QDomDocument& doc, QDomElement& element, co
|
||||
element.setAttribute( name, m_value );
|
||||
}
|
||||
|
||||
if( m_controllerConnection )
|
||||
if( m_controllerConnection && m_controllerConnection->getController()->type()
|
||||
!= Controller::DummyController )
|
||||
{
|
||||
QDomElement controllerElement;
|
||||
|
||||
|
||||
@@ -162,6 +162,11 @@ void ControllerConnection::finalizeConnections()
|
||||
c->setController( Engine::getSong()->
|
||||
controllers().at( c->m_controllerId ) );
|
||||
}
|
||||
else if (c->getController()->type() == Controller::DummyController)
|
||||
{
|
||||
delete c;
|
||||
--i;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -199,7 +204,7 @@ void ControllerConnection::loadSettings( const QDomElement & _this )
|
||||
}
|
||||
else
|
||||
{
|
||||
if( _this.attribute( "id" ).toInt() >= 0 )
|
||||
if( _this.attribute( "id", "-1" ).toInt() >= 0 )
|
||||
{
|
||||
m_controllerId = _this.attribute( "id" ).toInt();
|
||||
}
|
||||
|
||||
@@ -1122,6 +1122,11 @@ void Song::loadProject( const QString & fileName )
|
||||
// now that everything is loaded
|
||||
ControllerConnection::finalizeConnections();
|
||||
|
||||
// Remove dummy controllers that was added for correct connections
|
||||
m_controllers.erase(std::remove_if(m_controllers.begin(), m_controllers.end(),
|
||||
[](Controller* c){return c->type() == Controller::DummyController;}),
|
||||
m_controllers.end());
|
||||
|
||||
// resolve all IDs so that autoModels are automated
|
||||
AutomationPattern::resolveAllIDs();
|
||||
|
||||
@@ -1289,9 +1294,13 @@ void Song::restoreControllerStates( const QDomElement & element )
|
||||
while( !node.isNull() && !isCancelled() )
|
||||
{
|
||||
Controller * c = Controller::create( node.toElement(), this );
|
||||
Q_ASSERT( c != NULL );
|
||||
|
||||
addController( c );
|
||||
if (c) {addController(c);}
|
||||
else
|
||||
{
|
||||
// Fix indices to ensure correct connections
|
||||
m_controllers.append(Controller::create(
|
||||
Controller::DummyController, this));
|
||||
}
|
||||
|
||||
node = node.nextSibling();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user