Skip to content
Permalink
Browse files

fix #290323: synthesizer tag always written

  • Loading branch information...
jthistle committed Jun 8, 2019
1 parent bcbd94a commit 8cee28a3d3d77b773fab91a48b71fb257b7a8ecb
@@ -19,8 +19,11 @@ namespace Ms {
// write
//---------------------------------------------------------

void SynthesizerState::write(XmlWriter& xml) const
void SynthesizerState::write(XmlWriter& xml, bool force /* = false */) const
{
if (isDefault() && !force)
return;

xml.stag("Synthesizer");
for (const SynthesizerGroup& g : *this) {
if (!g.name().isEmpty()) {
@@ -52,6 +55,7 @@ void SynthesizerState::read(XmlReader& e)
e.unknown();
}
push_back(group);
setIsDefault(false);
}
}

@@ -53,19 +53,22 @@ class SynthesizerGroup : public std::list<IdValue> {
//---------------------------------------------------------

class SynthesizerState : public std::list<SynthesizerGroup> {
bool _isDefault { true };

public:
SynthesizerState(std::initializer_list<SynthesizerGroup> l) {
insert(end(), l.begin(), l.end());
}
SynthesizerState() : std::list<SynthesizerGroup>() {}

void write(XmlWriter&) const;
void write(XmlWriter&, bool force = false) const;
void read(XmlReader&);
SynthesizerGroup group(const QString& name) const;
bool isDefaultSynthSoundfont();
int ccToUse() const;
int method() const;
bool isDefault() const { return _isDefault; }
void setIsDefault(bool val) { _isDefault = val; }
};

//---------------------------------------------------------
@@ -355,14 +355,18 @@ void SynthControl::saveButtonClicked()
if (!_score)
return;
_score->startCmd();
_score->undo(new ChangeSynthesizerState(_score, synti->state()));
SynthesizerState ss = synti->state();
if (_dirty || !_score->synthesizerState().isDefault())
ss.setIsDefault(false);
_score->undo(new ChangeSynthesizerState(_score, ss));
_score->endCmd();

updateExpressivePatches();
loadButton->setEnabled(false);
saveButton->setEnabled(false);
storeButton->setEnabled(true);
recallButton->setEnabled(true);
_dirty = false;
}

//---------------------------------------------------------
@@ -391,6 +395,7 @@ void SynthControl::recallButtonClicked()
else
e.unknown();
}
state.setIsDefault(true);
synti->setState(state);
updateGui();

@@ -417,6 +422,7 @@ void SynthControl::storeButtonClicked()
updateExpressivePatches();
storeButton->setEnabled(false);
recallButton->setEnabled(false);
_dirty = false;
}

//---------------------------------------------------------
@@ -479,6 +485,7 @@ void SynthControl::updateMixer()

void SynthControl::setDirty()
{
_dirty = true;
loadButton->setEnabled(true);
saveButton->setEnabled(true);
storeButton->setEnabled(true);
@@ -36,6 +36,7 @@ class SynthControl : public QWidget, Ui::SynthControl {

Score* _score;
EnablePlayForWidget* enablePlay;
bool _dirty { false };

virtual void closeEvent(QCloseEvent*);
virtual void showEvent(QShowEvent*);
@@ -408,7 +408,9 @@ bool MasterSynthesizer::storeState()
}
XmlWriter xml(0, &f);
xml.header();
state().write(xml);
// force the write, since the msynth state is created when state() is called and so will
// automatically have _isDefault = true, when in fact we need to write the state here, default or not
state().write(xml, true);
return true;
}

0 comments on commit 8cee28a

Please sign in to comment.
You can’t perform that action at this time.