Skip to content

Commit

Permalink
fix #21704: imported chords do not render
Browse files Browse the repository at this point in the history
Recent changes to default style chordlist handling resulted in imported
scores never loading a chord list at all, causing them to render
incorrectly (no root or bass).  This is a proposed fix for that specific
issue that also addresses other potential problems in chordlist handling
(honoring the distinction between a truly empty chordlist and one that
merely contains no chord id's but does contain sym & token definitions).
  • Loading branch information
MarcSabatella committed Jun 30, 2013
1 parent f71d38a commit 9479346
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 3 deletions.
28 changes: 27 additions & 1 deletion libmscore/chordlist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1769,6 +1769,32 @@ bool ChordList::write(const QString& name) const
return true;
}

//---------------------------------------------------------
// loaded
//---------------------------------------------------------

}
bool ChordList::loaded() const
{
// track whether a description file has been loaded
// since chords.xml really doesn't load enough to stand alone,
// we need a way to track when a "real" chord list has been loaded
// for lack of anything better, key off renderListRoot
return !renderListRoot.isEmpty();
}

//---------------------------------------------------------
// unload
//---------------------------------------------------------

void ChordList::unload()
{
clear();
symbols.clear();
fonts.clear();
renderListRoot.clear();
renderListBase.clear();
chordTokenList.clear();
}


}
2 changes: 2 additions & 0 deletions libmscore/chordlist.h
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,8 @@ class ChordList : public QMap<int, ChordDescription*> {
void read(XmlReader&);
bool read(const QString&);
bool write(const QString&) const;
bool loaded() const;
void unload();
ChordSymbol symbol(const QString& s) const { return symbols.value(s); }
};

Expand Down
4 changes: 2 additions & 2 deletions libmscore/style.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1072,11 +1072,11 @@ void StyleData::load(XmlReader& e)
_customChordList = true;
else
_customChordList = false;
_chordList.clear();
_chordList.unload();
}

// make sure we have a chordlist
if (_chordList.isEmpty() && !chordListTag) {
if (!_chordList.loaded() && !chordListTag) {
if (value(ST_chordsXmlFile).toBool())
_chordList.read("chords.xml");
_chordList.read(newChordDescriptionFile);
Expand Down
1 change: 1 addition & 0 deletions mscore/bb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,7 @@ Score::FileError importBB(Score* score, const QString& name)
qDebug("cannot open file <%s>\n", qPrintable(name));
return Score::FILE_OPEN_ERROR;
}
score->style()->set(StyleVal(ST_chordsXmlFile, true));
score->style()->chordList()->read("chords.xml");
*(score->sigmap()) = bb.siglist();

Expand Down
5 changes: 5 additions & 0 deletions mscore/file.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1773,6 +1773,11 @@ Score::FileError readScore(Score* score, QString name, bool ignoreVersionError)
if (f.open(QIODevice::ReadOnly))
score->style()->load(&f);
}
else {
if (score->style()->value(ST_chordsXmlFile).toBool())
score->style()->chordList()->read("chords.xml");
score->style()->chordList()->read(score->style()->valueSt(ST_chordDescriptionFile));
}
uint n = sizeof(imports)/sizeof(*imports);
uint i;
for (i = 0; i < n; ++i) {
Expand Down

0 comments on commit 9479346

Please sign in to comment.