From 07021ed84bca706c45f426f92a6208849dcbd646 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s?= Date: Sun, 14 Aug 2016 17:18:12 -0300 Subject: [PATCH] fix 'Set Linear' not saving properly (#1642) (#2742) --- include/DataFile.h | 1 + src/core/AutomatableModel.cpp | 18 ++++++---- src/core/DataFile.cpp | 64 +++++++++++++++++++++++++++++++++++ 3 files changed, 77 insertions(+), 6 deletions(-) diff --git a/include/DataFile.h b/include/DataFile.h index 99c3b3ff0..57882bc0e 100644 --- a/include/DataFile.h +++ b/include/DataFile.h @@ -122,6 +122,7 @@ private: void upgrade_0_4_0_20080622(); void upgrade_0_4_0_beta1(); void upgrade_0_4_0_rc2(); + void upgrade_1_0_99(); void upgrade_1_1_0(); void upgrade_1_1_91(); diff --git a/src/core/AutomatableModel.cpp b/src/core/AutomatableModel.cpp index 90c07b9fb..751c8b54d 100644 --- a/src/core/AutomatableModel.cpp +++ b/src/core/AutomatableModel.cpp @@ -195,14 +195,20 @@ void AutomatableModel::loadSettings( const QDomElement& element, const QString& } } } - else if( element.hasAttribute( name ) ) - // attribute => read the element's value from the attribute list - { - setInitValue( element.attribute( name ).toFloat() ); - } else { - reset(); + + setScaleType( Linear ); + + if( element.hasAttribute( name ) ) + // attribute => read the element's value from the attribute list + { + setInitValue( element.attribute( name ).toFloat() ); + } + else + { + reset(); + } } } diff --git a/src/core/DataFile.cpp b/src/core/DataFile.cpp index 8222b2d04..8ac8b58f9 100644 --- a/src/core/DataFile.cpp +++ b/src/core/DataFile.cpp @@ -39,12 +39,15 @@ #include "Effect.h" #include "embed.h" #include "GuiApplication.h" +#include "lmms_basics.h" #include "lmmsversion.h" #include "PluginFactory.h" #include "ProjectVersion.h" #include "SongEditor.h" #include "TextFloat.h" +static void findIds(const QDomElement& elem, QList& idList); + @@ -794,6 +797,47 @@ void DataFile::upgrade_0_4_0_rc2() } +void DataFile::upgrade_1_0_99() +{ + jo_id_t last_assigned_id = 0; + + QList idList; + findIds(documentElement(), idList); + + QDomNodeList list = elementsByTagName("ladspacontrols"); + for(int i = 0; !list.item(i).isNull(); ++i) + { + for(QDomNode node = list.item(i).firstChild(); !node.isNull(); + node = node.nextSibling()) + { + QDomElement el = node.toElement(); + QDomNode data_child = el.namedItem("data"); + if(!data_child.isElement()) + { + if (el.attribute("scale_type") == "log") + { + QDomElement me = createElement("data"); + me.setAttribute("value", el.attribute("data")); + me.setAttribute("scale_type", "log"); + + jo_id_t id; + for(id = last_assigned_id + 1; + idList.contains(id); id++) + { + } + + last_assigned_id = id; + idList.append(id); + me.setAttribute("id", id); + el.appendChild(me); + + } + } + } + } +} + + void DataFile::upgrade_1_1_0() { QDomNodeList list = elementsByTagName("fxchannel"); @@ -895,6 +939,10 @@ void DataFile::upgrade() { upgrade_0_4_0_rc2(); } + if( version < ProjectVersion("1.0.99", CompareType::Release) ) + { + upgrade_1_0_99(); + } if( version < ProjectVersion("1.1.0", CompareType::Release) ) { upgrade_1_1_0(); @@ -1007,3 +1055,19 @@ void DataFile::loadData( const QByteArray & _data, const QString & _sourceFile ) m_content = root.elementsByTagName( typeName( m_type ) ). item( 0 ).toElement(); } + + +void findIds(const QDomElement& elem, QList& idList) +{ + if(elem.hasAttribute("id")) + { + idList.append(elem.attribute("id").toInt()); + } + QDomElement child = elem.firstChildElement(); + while(!child.isNull()) + { + findIds(child, idList); + child = child.nextSiblingElement(); + } +} +