Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix 'Set Linear' not saving properly (#1642) #2742

Merged
merged 3 commits into from Aug 14, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions include/DataFile.h
Expand Up @@ -122,6 +122,7 @@ class EXPORT DataFile : public QDomDocument
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();

Expand Down
18 changes: 12 additions & 6 deletions src/core/AutomatableModel.cpp
Expand Up @@ -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();
}
}
}

Expand Down
64 changes: 64 additions & 0 deletions src/core/DataFile.cpp
Expand Up @@ -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<jo_id_t>& idList);




Expand Down Expand Up @@ -794,6 +797,47 @@ void DataFile::upgrade_0_4_0_rc2()
}


void DataFile::upgrade_1_0_99()
{
jo_id_t last_assigned_id = 0;

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Empty lines should not have any indentation, but coding conventions are not against this.

QList<jo_id_t> 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");
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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<jo_id_t>& idList)
{
if(elem.hasAttribute("id"))
{
idList.append(elem.attribute("id").toInt());
}
QDomElement child = elem.firstChildElement();
while(!child.isNull())
{
findIds(child, idList);
child = child.nextSiblingElement();
}
}