Skip to content

Commit

Permalink
fix #28331
Browse files Browse the repository at this point in the history
  • Loading branch information
wschweer committed Jul 27, 2014
1 parent 66fcc16 commit e8e5f99
Show file tree
Hide file tree
Showing 9 changed files with 51 additions and 80 deletions.
22 changes: 0 additions & 22 deletions libmscore/cleflist.cpp
Expand Up @@ -62,27 +62,5 @@ void ClefList::setClef(int tick, ClefTypeList ctl)
i->second = ctl;
}

#if 0
//---------------------------------------------------------
// ClefList::read
// only used for 1.3 scores
//---------------------------------------------------------

void ClefList::read(XmlReader& e, Score* cs)
{
clear();
while (e.readNextStartElement()) {
if (e.name() == "clef") {
int tick = e.intAttribute("tick", 0);
ClefType ct = Clef::clefType(e.attribute("idx", "0"));
insert(std::pair<int, ClefTypeList>(cs->fileDivision(tick), ClefTypeList(ct, ct)));
e.readNext();
}
else
e.unknown();
}
}
#endif

}

6 changes: 2 additions & 4 deletions libmscore/cleflist.h
Expand Up @@ -31,10 +31,8 @@ class ClefList : public std::map<int, ClefTypeList> {
ClefList() {}
ClefTypeList clef(int tick) const;
void setClef(int tick, ClefTypeList);
void setInitial(ClefTypeList cl) { _initial = cl; }

// void read(XmlReader&, Score*);

void setInitial(ClefTypeList cl) { _initial = cl; }
ClefTypeList initial() const { return _initial; }
};


Expand Down
37 changes: 28 additions & 9 deletions libmscore/measure.cpp
Expand Up @@ -1107,30 +1107,49 @@ void Measure::cmdAddStaves(int sStaff, int eStaff, bool createRest)
// ms->lines->setLines(staff->lines());
ms->lines->setParent(this);
ms->lines->setVisible(!staff->invisible());

_score->undo(new InsertMStaff(this, ms, i));
}

if (createRest) {
if (_timesig != len()) {
score()->setRest(tick(), i * VOICES, len(), false, 0, false);
}
else {
score()->setRest(tick(), i * VOICES, len(), false, 0, true);
if (!createRest && !ts)
return;


// create list of unique staves (only one instance for linked staves):

QList<int> sl;
for (int staffIdx = sStaff; staffIdx < eStaff; ++staffIdx) {
Staff* s = _score->staff(staffIdx);
if (s->linkedStaves()) {
bool alreadyInList = false;
for (int idx : sl) {
if (s->linkedStaves()->staves().contains(_score->staff(idx))) {
alreadyInList = true;
break;
}
}
if (alreadyInList)
continue;
}
sl.append(staffIdx);
}

for (int staffIdx : sl) {
if (createRest)
score()->setRest(tick(), staffIdx * VOICES, len(), false, 0, _timesig == len());

// replicate time signature
if (ts) {
TimeSig* ots = 0;
for (int track = 0; track < staves.size() * VOICES; ++track) {
if (ts->element(track)) {
ots = (TimeSig*)ts->element(track);
ots = static_cast<TimeSig*>(ts->element(track));
break;
}
}
if (ots) {
TimeSig* timesig = new TimeSig(*ots);
timesig->setTrack(i * VOICES);
timesig->setTrack(staffIdx * VOICES);
timesig->setParent(ts);
timesig->setSig(ots->sig(), ots->timeSigType());
score()->undoAddElement(timesig);
}
Expand Down
18 changes: 11 additions & 7 deletions libmscore/staff.cpp
Expand Up @@ -745,16 +745,22 @@ void Staff::setStaffType(const StaffType* st)
// check for right clef-type and fix
// if necessary
//
ClefType ct = clef(0);
ClefType ct = clefs.initial()._concertClef;
StaffGroup csg = ClefInfo::staffGroup(ct);

if (_staffType.group() != csg) {
switch(_staffType.group()) {
case StaffGroup::TAB: ct = ClefType(score()->styleI(StyleIdx::tabClef)); break;
case StaffGroup::STANDARD: ct = ClefType::G; break; // TODO: use preferred clef for instrument
case StaffGroup::PERCUSSION: ct = ClefType::PERC; break;
case StaffGroup::TAB:
ct = ClefType(score()->styleI(StyleIdx::tabClef));
break;
case StaffGroup::STANDARD:
ct = ClefType::G; // TODO: use preferred clef for instrument
break;
case StaffGroup::PERCUSSION:
ct = ClefType::PERC;
break;
}
clefs.setClef(0, ClefTypeList(ct, ct));
setInitialClef(ct);
}
}

Expand All @@ -767,11 +773,9 @@ void Staff::init(const InstrumentTemplate* t, const StaffType* staffType, int ci
// set staff-type-independent parameters
if (cidx > MAX_STAVES) {
setSmall(false);
clefs.setClef(0, t->clefTypes[0]);
}
else {
setSmall(t->smallStaff[cidx]);
clefs.setClef(0, t->clefTypes[cidx]); // initial clef will be fixed to staff-type clef by setStaffType()
setBracket(0, t->bracket[cidx]);
setBracketSpan(0, t->bracketSpan[cidx]);
setBarLineSpan(t->barlineSpan[cidx]);
Expand Down
10 changes: 3 additions & 7 deletions libmscore/undo.cpp
Expand Up @@ -1175,21 +1175,17 @@ void Score::undoAddCR(ChordRest* cr, Measure* measure, int tick)
{
Q_ASSERT(cr->type() != Element::Type::CHORD || !(static_cast<Chord*>(cr)->notes()).isEmpty());

QList<Staff*> staffList;
Staff* ostaff = cr->staff();
LinkedStaves* linkedStaves = ostaff->linkedStaves();
if (linkedStaves)
staffList = linkedStaves->staves();
else
staffList.append(ostaff);
Segment::Type segmentType = Segment::Type::ChordRest;

Tuplet* t = cr->tuplet();
foreach (Staff* staff, staffList) {
foreach (Staff* staff, ostaff->staffList()) {
Score* score = staff->score();
Measure* m = (score == this) ? measure : score->tick2measure(tick);
Segment* seg = m->undoGetSegment(segmentType, tick);

Q_ASSERT(seg->segmentType() == segmentType);

ChordRest* newcr = (staff == ostaff) ? cr : static_cast<ChordRest*>(cr->linkedClone());
newcr->setScore(score);
int staffIdx = score->staffIdx(staff);
Expand Down
28 changes: 5 additions & 23 deletions mscore/instrdialog.cpp
Expand Up @@ -965,31 +965,13 @@ void MuseScore::editInstrList()
}
if (linked.size() == 0)
part->staves()->front()->setBarLineSpan(part->nstaves());
//equivalent to cmdInsertPart(part, staffIdx)
// but we donnt add rests for linked parts
rootScore->undoInsertPart(part, staffIdx);
for (Staff* s : nonLinked) {
int si = rootScore->staffIdx(s);
for (Measure* m = rootScore->firstMeasure(); m; m = m->nextMeasure()) {
m->cmdAddStaves(si, si + 1, true);
if (m->hasMMRest())
//m->mmRest()->cmdAddStaves(si, si + 1, true);
m->mmRest()->cmdAddStaves(si, si + 1, false);
}
}
for (Staff* s : linked) {
int si = rootScore->staffIdx(s);
for (Measure* m = rootScore->firstMeasure(); m; m = m->nextMeasure()) {
m->cmdAddStaves(si, si + 1, false);
if (m->hasMMRest())
m->mmRest()->cmdAddStaves(si, si + 1, true);
}
}

rootScore->cmdInsertPart(part, staffIdx);

//insert keysigs
int sidx = rootScore->staffIdx(part);
int eidx = sidx + part->nstaves();
rootScore->adjustBracketsIns(sidx, eidx);
//insert keysigs
if(firstStaff)
if (firstStaff)
rootScore->adjustKeySigs(sidx, eidx, tmpKeymap);
staffIdx += rstaff;
}
Expand Down
4 changes: 2 additions & 2 deletions mscore/pulseaudio.cpp
Expand Up @@ -137,7 +137,7 @@ bool PulseAudio::init(bool)

pa_stream* playstream = pa_stream_new(pa_ctx, "Playback", &ss, NULL);
if (!playstream) {
printf("pa_stream_new failed\n");
qDebug("pa_stream_new failed");
return false;
}
pa_stream_set_write_callback(playstream, paCallback, this);
Expand All @@ -161,7 +161,7 @@ bool PulseAudio::init(bool)
NULL, NULL);
}
if (r < 0) {
printf("pa_stream_connect_playback failed\n");
qDebug("pa_stream_connect_playback failed");
pa_context_disconnect(pa_ctx);
pa_context_unref(pa_ctx);
pa_mainloop_free(pa_ml);
Expand Down
5 changes: 0 additions & 5 deletions mscore/scoreview.cpp
Expand Up @@ -4706,7 +4706,6 @@ void ScoreView::cmdAddPitch(int note, bool addFlag)
qDebug("cannot enter notes here (no chord rest at current position)");
return;
}
printf("cmdAddPitch %p\n", is.segment());
Drumset* ds = is.drumset();
int octave = 4;
if (ds) {
Expand Down Expand Up @@ -4743,7 +4742,6 @@ printf("cmdAddPitch %p\n", is.segment());
else {
int curPitch = -1;
if (is.segment()) {
printf(" cmdAddPitch1 %p\n", is.segment());
Staff* staff = score()->staff(is.track() / VOICES);
Segment* seg = is.segment()->prev1(Segment::Type::ChordRest | Segment::Type::Clef);
while(seg) {
Expand Down Expand Up @@ -4778,16 +4776,13 @@ printf(" cmdAddPitch1 %p\n", is.segment());
--octave;
else if (delta < -6)
++octave;
printf(" cmdAddPitch2 %p\n", is.segment());
}
}

if (!noteEntryMode()) {
sm->postEvent(new CommandEvent("note-input"));
qApp->processEvents();
printf(" cmdAddPitch3 %p\n", is.segment());
}
printf(" cmdAddPitch4 %p\n", is.segment());
_score->cmdAddPitch(octave * 7 + note, addFlag);
adjustCanvasPosition(is.cr(), false);
}
Expand Down
1 change: 0 additions & 1 deletion mscore/textpalette.cpp
Expand Up @@ -79,7 +79,6 @@ TextPalette::TextPalette(QWidget* parent)

void TextPalette::pageChanged(int idx)
{
printf("page changed %d\n", idx);
}

//---------------------------------------------------------
Expand Down

0 comments on commit e8e5f99

Please sign in to comment.