fixes #6736: Sample tracks lose FX Channel (#6851)

* fixes #6736: Sample tracks lose FX Channel

* Styling fixes

* Restyled remaining blocks of upgrade routine

* Fixed hang due to sleepy typo

* Update src/core/DataFile.cpp

Co-authored-by: saker <sakertooth@gmail.com>

---------

Co-authored-by: saker <sakertooth@gmail.com>
This commit is contained in:
consolegrl
2023-09-12 18:08:06 -04:00
committed by GitHub
parent 89baab6b87
commit 3a0e68c0ac

View File

@@ -1704,26 +1704,56 @@ void DataFile::upgrade_mixerRename()
{
// Change nodename <fxmixer> to <mixer>
QDomNodeList fxmixer = elementsByTagName("fxmixer");
for (int i = 0; !fxmixer.item(i).isNull(); ++i)
for (int i = 0; i < fxmixer.length(); ++i)
{
fxmixer.item(i).toElement().setTagName("mixer");
auto item = fxmixer.item(i).toElement();
if (item.isNull())
{
continue;
}
item.setTagName("mixer");
}
// Change nodename <fxchannel> to <mixerchannel>
QDomNodeList fxchannel = elementsByTagName("fxchannel");
for (int i = 0; !fxchannel.item(i).isNull(); ++i)
for (int i = 0; i < fxchannel.length(); ++i)
{
fxchannel.item(i).toElement().setTagName("mixerchannel");
auto item = fxchannel.item(i).toElement();
if (item.isNull())
{
continue;
}
item.setTagName("mixerchannel");
}
// Change the attribute fxch of element <instrumenttrack> to mixch
QDomNodeList fxch = elementsByTagName("instrumenttrack");
for(int i = 0; !fxch.item(i).isNull(); ++i)
for (int i = 0; i < fxch.length(); ++i)
{
if(fxch.item(i).toElement().hasAttribute("fxch"))
auto item = fxch.item(i).toElement();
if (item.isNull())
{
fxch.item(i).toElement().setAttribute("mixch", fxch.item(i).toElement().attribute("fxch"));
fxch.item(i).toElement().removeAttribute("fxch");
continue;
}
if (item.hasAttribute("fxch"))
{
item.setAttribute("mixch", item.attribute("fxch"));
item.removeAttribute("fxch");
}
}
// Change the attribute fxch of element <sampletrack> to mixch
fxch = elementsByTagName("sampletrack");
for (int i = 0; i < fxch.length(); ++i)
{
auto item = fxch.item(i).toElement();
if (item.isNull())
{
continue;
}
if (item.hasAttribute("fxch"))
{
item.setAttribute("mixch", item.attribute("fxch"));
item.removeAttribute("fxch");
}
}
}