Fix saving of multiple TempoSyncKnobModels (#3281)
* Save multiple TempSyncKnobModel syncmodes * Add upgrade path for approximate version 1.2.0-rc2.42
This commit is contained in:
committed by
Javier Serrano Polo
parent
284c40c80b
commit
c1321ba80f
@@ -126,6 +126,7 @@ private:
|
||||
void upgrade_1_1_0();
|
||||
void upgrade_1_1_91();
|
||||
void upgrade_1_2_0_rc3();
|
||||
void upgrade_1_2_0_rc2_42();
|
||||
|
||||
void upgrade();
|
||||
|
||||
|
||||
@@ -929,6 +929,49 @@ void DataFile::upgrade_1_2_0_rc3()
|
||||
}
|
||||
|
||||
|
||||
static void upgradeElement_1_2_0_rc2_42( QDomElement & el )
|
||||
{
|
||||
if( el.hasAttribute( "syncmode" ) )
|
||||
{
|
||||
int syncmode = el.attribute( "syncmode" ).toInt();
|
||||
QStringList names;
|
||||
QDomNamedNodeMap atts = el.attributes();
|
||||
for( uint i = 0; i < atts.length(); i++ )
|
||||
{
|
||||
QString name = atts.item( i ).nodeName();
|
||||
if( name.endsWith( "_numerator" ) )
|
||||
{
|
||||
names << name.remove( "_numerator" )
|
||||
+ "_syncmode";
|
||||
}
|
||||
}
|
||||
for( QStringList::iterator it = names.begin(); it < names.end();
|
||||
++it )
|
||||
{
|
||||
el.setAttribute( *it, syncmode );
|
||||
}
|
||||
}
|
||||
|
||||
QDomElement child = el.firstChildElement();
|
||||
while ( !child.isNull() )
|
||||
{
|
||||
upgradeElement_1_2_0_rc2_42( child );
|
||||
child = child.nextSiblingElement();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void DataFile::upgrade_1_2_0_rc2_42()
|
||||
{
|
||||
QDomElement el = firstChildElement();
|
||||
while ( !el.isNull() )
|
||||
{
|
||||
upgradeElement_1_2_0_rc2_42( el );
|
||||
el = el.nextSiblingElement();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void DataFile::upgrade()
|
||||
{
|
||||
ProjectVersion version =
|
||||
@@ -1008,6 +1051,7 @@ void DataFile::upgrade()
|
||||
if( version < "1.2.0-rc3" )
|
||||
{
|
||||
upgrade_1_2_0_rc3();
|
||||
upgrade_1_2_0_rc2_42();
|
||||
}
|
||||
|
||||
// update document meta data
|
||||
|
||||
@@ -127,7 +127,7 @@ void TempoSyncKnobModel::calculateTempoSyncTime( bpm_t _bpm )
|
||||
void TempoSyncKnobModel::saveSettings( QDomDocument & _doc, QDomElement & _this,
|
||||
const QString & _name )
|
||||
{
|
||||
_this.setAttribute( "syncmode", (int) syncMode() );
|
||||
_this.setAttribute( _name + "_syncmode", (int) syncMode() );
|
||||
m_custom.saveSettings( _doc, _this, _name );
|
||||
FloatModel::saveSettings( _doc, _this, _name );
|
||||
}
|
||||
@@ -140,7 +140,7 @@ void TempoSyncKnobModel::loadSettings( const QDomElement & _this,
|
||||
{
|
||||
FloatModel::loadSettings( _this, _name );
|
||||
m_custom.loadSettings( _this, _name );
|
||||
setSyncMode( ( TempoSyncMode ) _this.attribute( "syncmode" ).toInt() );
|
||||
setSyncMode( ( TempoSyncMode ) _this.attribute( _name + "_syncmode" ).toInt() );
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user