Skip to content

Commit

Permalink
engine/scene: preserve fixture order when saving on XML
Browse files Browse the repository at this point in the history
This might be a bit less efficient than before, but it is more consistent in terms of user experience,
especially when empty fixtures are left in a Scene
  • Loading branch information
mcallegari committed Apr 24, 2017
1 parent 0707e7e commit 83761c3
Showing 1 changed file with 27 additions and 27 deletions.
54 changes: 27 additions & 27 deletions engine/src/scene.cpp
Expand Up @@ -364,37 +364,37 @@ bool Scene::saveXML(QXmlStreamWriter *doc)
}

/* Scene contents */
QList<quint32> writtenFixtures;
QMapIterator <SceneValue, uchar> it(m_values);
qint32 currFixID = -1;
QStringList currFixValues;
while (it.hasNext() == true)
// make a copy of the Scene values cause we need to empty it in the process
QList<SceneValue> values = m_values.keys();

// loop through the Scene Fixtures in the order they've been added
foreach (quint32 fxId, m_fixtures)
{
SceneValue sv = it.next().key();
if (currFixID == -1) currFixID = sv.fxi;
if ((qint32)sv.fxi != currFixID)
QStringList currFixValues;
bool found = false;

// look for the values that match the current Fixture ID
for (int j = 0; j < values.count(); j++)
{
saveXMLFixtureValues(doc, currFixID, currFixValues);
writtenFixtures << currFixID;
currFixValues.clear();
currFixID = sv.fxi;
}
currFixValues.append(QString::number(sv.channel));
// IMPORTANT: if a Scene is hidden, so used as a container by some Sequences,
// it must be saved with values set to zero
currFixValues.append(QString::number(isVisible() ? sv.value : 0));
}
/* write last element */
saveXMLFixtureValues(doc, currFixID, currFixValues);
writtenFixtures << currFixID;
SceneValue scv = values.at(j);
if (scv.fxi != fxId)
{
if (found == true)
break;
else
continue;
}

// Write fixtures with no scene value
foreach(quint32 fixtureID, m_fixtures)
{
if (writtenFixtures.contains(fixtureID))
continue;
found = true;
currFixValues.append(QString::number(scv.channel));
// IMPORTANT: if a Scene is hidden, so used as a container by some Sequences,
// it must be saved with values set to zero
currFixValues.append(QString::number(isVisible() ? scv.value : 0));
values.removeAt(j);
j--;
}

saveXMLFixtureValues(doc, fixtureID, QStringList());
saveXMLFixtureValues(doc, fxId, currFixValues);
}

/* End the <Function> tag */
Expand Down

1 comment on commit 83761c3

@mdmayfield
Copy link
Contributor

Choose a reason for hiding this comment

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

This commit causes an issue when duplicating Scenes, as described here: http://www.qlcplus.org/forum/viewtopic.php?f=21&t=11144

Please sign in to comment.