Add a fallback to Symbol::read() to recognize 'old' symbol names
Sym::name2id() returs noSym if name not found
This commit is contained in:
parent
63bb3f1b27
commit
fd4054599e
3 changed files with 16 additions and 9 deletions
|
@ -569,12 +569,12 @@ void Sym::init()
|
|||
|
||||
// #define MT(a) QT_TRANSLATE_NOOP("symbol", a)
|
||||
|
||||
symNames[clefEightSym] = "clef eight";
|
||||
symNames[clefOneSym] = "clef one";
|
||||
symNames[clefFiveSym] = "clef five";
|
||||
symNames[letterTSym] = "T";
|
||||
symNames[letterSSym] = "S";
|
||||
symNames[letterPSym] = "P";
|
||||
symUserNames[clefEightSym] = symNames[clefEightSym] = "clef eight";
|
||||
symUserNames[clefOneSym] = symNames[clefOneSym] = "clef one";
|
||||
symUserNames[clefFiveSym] = symNames[clefFiveSym] = "clef five";
|
||||
symUserNames[letterTSym] = symNames[letterTSym] = "T";
|
||||
symUserNames[letterSSym] = symNames[letterSSym] = "S";
|
||||
symUserNames[letterPSym] = symNames[letterPSym] = "P";
|
||||
|
||||
for (unsigned i = 0; pSymbols[i].code != -1; ++i) {
|
||||
if (pSymbols[i].code == 0 || pSymbols[i].text == 0)
|
||||
|
|
|
@ -361,9 +361,10 @@ class Sym {
|
|||
QPointF getAttach() const { return _attach; }
|
||||
QString toString() const;
|
||||
|
||||
static SymId name2id(const QString& s) { return lnhash[s]; }
|
||||
static SymId name2id(const QString& s) { return lnhash.value(s, noSym); } // return noSym if not found
|
||||
static const char* id2name(SymId id) { return symNames[id]; }
|
||||
static QString id2userName(SymId id) { return symUserNames[id]; }
|
||||
static SymId userName2id(const QString& s) { return (SymId)(symUserNames.indexOf(s)); }
|
||||
static void init();
|
||||
};
|
||||
|
||||
|
|
|
@ -245,8 +245,14 @@ void Symbol::read(const QDomElement& de)
|
|||
if (tag == "name") {
|
||||
s = Sym::name2id(val);
|
||||
if (s == noSym) {
|
||||
qDebug("unknown symbol <%s>, symbols %d\n",
|
||||
qPrintable(val), symbols[0].size());
|
||||
// if symbol name not found, fall back to mnames
|
||||
s = Sym::userName2id(val);
|
||||
if (s == noSym) {
|
||||
qDebug("unknown symbol <%s> (%d symbols), defaulting to diamond head\n",
|
||||
qPrintable(val), symbols[0].size());
|
||||
// set a default symbol, or layout() will crash
|
||||
s = diamondheadSym;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (tag == "Symbol") {
|
||||
|
|
Loading…
Reference in a new issue