diff --git a/libmscore/groups.cpp b/libmscore/groups.cpp index b6c7c8b28665..fcfc79885c4e 100644 --- a/libmscore/groups.cpp +++ b/libmscore/groups.cpp @@ -231,9 +231,9 @@ void Groups::addStop(int pos, TDuration::DurationType d, BeamMode bm) void Groups::dump(const char* m) const { - printf("%s\n", m); + qDebug("%s", m); for (const GroupNode& n : *this) { - printf(" group tick %d action 0x%02x\n", n.pos * 60, n.action); + qDebug(" group tick %d action 0x%02x", n.pos * 60, n.action); } } diff --git a/libmscore/score.cpp b/libmscore/score.cpp index a3352238766d..6ae7b886972b 100644 --- a/libmscore/score.cpp +++ b/libmscore/score.cpp @@ -1959,6 +1959,15 @@ Q_INVOKABLE void Score::setMetaTag(const QString& tag, const QString& val) _metaTags.insert(tag, val); } +//--------------------------------------------------------- +// staffTypes +//--------------------------------------------------------- + +const QList& Score::staffTypes() const + { + return rootScore()->_staffTypes; + } + //--------------------------------------------------------- // addStaffType // ownership of st move to score except if the buildin @@ -1972,22 +1981,23 @@ void Score::addStaffType(StaffType* st) void Score::addStaffType(int idx, StaffType* st) { + Score* s = rootScore(); // if the modified staff type is NOT replacing an existing type - if (idx < 0 || idx >= _staffTypes.size()) { + if (idx < 0 || idx >= s->_staffTypes.size()) { // store new pointer to pointer to type data StaffType** stp = new StaffType*; *stp = st; - _staffTypes.append(stp); + s->_staffTypes.append(stp); } // if the modified staff type IS replacing an existing type else { StaffType* oldStaffType = *(_staffTypes[idx]); // update the type of each score staff which uses the old type - for(int staffIdx = 0; staffIdx < staves().size(); staffIdx++) - if(staff(staffIdx)->staffType() == oldStaffType) + for (int staffIdx = 0; staffIdx < staves().size(); staffIdx++) + if (staff(staffIdx)->staffType() == oldStaffType) staff(staffIdx)->setStaffType(st); // store the updated staff type - *(_staffTypes[idx]) = st; + *(s->_staffTypes[idx]) = st; // delete old staff type if not built-in if (!oldStaffType->builtin()) delete oldStaffType; @@ -2000,8 +2010,9 @@ void Score::addStaffType(int idx, StaffType* st) int Score::staffTypeIdx(StaffType* st) const { + const Score* s = rootScore(); for (int i = 0; i < _staffTypes.size(); ++i) { - if ((*_staffTypes[i]) == st) + if ((*s->_staffTypes[i]) == st) return i; } return -1; @@ -2011,11 +2022,12 @@ int Score::staffTypeIdx(StaffType* st) const // staffType //--------------------------------------------------------- -StaffType* Score::staffType(int idx) +StaffType* Score::staffType(int idx) const { - if (idx < 0 || idx >= _staffTypes.size()) + const Score* s = rootScore(); + if (idx < 0 || idx >= s->_staffTypes.size()) return 0; - return *(_staffTypes[idx]); + return *(s->_staffTypes[idx]); } //--------------------------------------------------------- diff --git a/libmscore/score.h b/libmscore/score.h index 40db275eb7da..55c62b349bca 100644 --- a/libmscore/score.h +++ b/libmscore/score.h @@ -847,9 +847,9 @@ class Score : public QObject { SynthesizerState& synthesizerState() { return _synthesizerState; } void setSynthesizerState(const SynthesizerState& s); - const QList& staffTypes() const { return _staffTypes; } + const QList& staffTypes() const; void replaceStaffTypes(const QList&); - StaffType* staffType(int idx); + StaffType* staffType(int idx) const; int staffTypeIdx(StaffType*) const; void addStaffType(StaffType*); void addStaffType(int idx, StaffType*); diff --git a/libmscore/staff.cpp b/libmscore/staff.cpp index 474fdec2101e..284b03afd912 100644 --- a/libmscore/staff.cpp +++ b/libmscore/staff.cpp @@ -425,6 +425,8 @@ void Staff::read(XmlReader& e) _barLineFrom = (lines() == 1 ? BARLINE_SPAN_1LINESTAFF_FROM : 0); _barLineTo = (lines() == 1 ? BARLINE_SPAN_1LINESTAFF_TO : (lines() - 1) * 2); } + else + qDebug("Staff::read: unknown staff type"); } else if (tag == "small") setSmall(e.readInt()); diff --git a/mscore/editstaff.cpp b/mscore/editstaff.cpp index f114107b50a3..5e37beb08cbc 100644 --- a/mscore/editstaff.cpp +++ b/mscore/editstaff.cpp @@ -83,13 +83,13 @@ EditStaff::EditStaff(Staff* s, QWidget* parent) void EditStaff::fillStaffTypeCombo() { Score* score = staff->score(); - int curIdx = 0; - int n = score->staffTypes().size(); + int curIdx = -1; // can this instrument accept tabs or drum set? bool canUseTabs = instrument.stringData() && instrument.stringData()->strings() > 0; bool canUsePerc = instrument.useDrumset(); staffType->clear(); - for (int idx = 0; idx < n; ++idx) { + + for (int idx = 0; idx < score->staffTypes().size(); ++idx) { StaffType* st = score->staffType(idx); if ( (canUseTabs && st->group() == TAB_STAFF_GROUP) || ( canUsePerc && st->group() == PERCUSSION_STAFF_GROUP) @@ -99,7 +99,9 @@ void EditStaff::fillStaffTypeCombo() curIdx = staffType->count() - 1; } } - staffType->setCurrentIndex(curIdx); + if (curIdx == -1) + qDebug("EditStaff::fillStaffTypeCombo: staff type not found"); + staffType->setCurrentIndex(curIdx == -1 ? 0 : curIdx); } //---------------------------------------------------------