Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Port PRs from 3.x #7528

Merged
merged 7 commits into from
Feb 15, 2021
2 changes: 1 addition & 1 deletion src/libmscore/beam.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1826,7 +1826,7 @@ void Beam::layout2(std::vector<ChordRest*> crl, SpannerSegmentType, int frag)
for (; i < n; ++i) {
ChordRest* c = crl[i];
ChordRest* p = i ? crl[i - 1] : 0;
int l = c->durationType().hooks() - 1;
int l = c->isChord() ? c->durationType().hooks() - 1 : beamLevel;

Mode bm = Groups::endBeam(c, p);
b32 = (beamLevel >= 1) && (bm == Mode::BEGIN32);
Expand Down
5 changes: 5 additions & 0 deletions src/libmscore/chord.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2759,7 +2759,12 @@ Element* Chord::drop(EditData& data)
}
}
if (tremolo()) {
bool sameType = (e->subtype() == tremolo()->subtype());
score()->undoRemoveElement(tremolo());
if (sameType) {
delete e;
return 0;
}
}
e->setParent(this);
e->setTrack(track());
Expand Down
14 changes: 8 additions & 6 deletions src/libmscore/edit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1016,12 +1016,6 @@ bool Score::rewriteMeasures(Measure* fm, const Fraction& ns, int staffIdx)
break;
}
}
} else {
// this can be hit for local time signatures as well
// (if we are rewriting all staves, but one has a local time signature)
// TODO: detect error conditions better, have clearer error messages
// and perform necessary fixups
MScore::setError(MsError::TUPLET_CROSSES_BAR);
}
for (Measure* m = fm1; m; m = m->nextMeasure()) {
if (m->first(SegmentType::TimeSig)) {
Expand Down Expand Up @@ -3072,6 +3066,14 @@ void Score::cmdDeleteSelection()
tick = toMeasureRepeat(e)->firstMeasureOfGroup()->first()->tick();
} else if (e->isSpannerSegment()) {
tick = toSpannerSegment(e)->spanner()->tick();
} else if (e->isBreath()) {
// we want the tick of the ChordRest that precedes the breath mark (in the same track)
for (Segment* s = toBreath(e)->segment()->prev(); s; s = s->prev()) {
if (s->isChordRestType() && s->element(e->track())) {
tick = s->tick();
break;
}
}
} else if (e->parent()
&& (e->parent()->isSegment() || e->parent()->isChord() || e->parent()->isNote() || e->parent()->isRest())) {
tick = e->parent()->tick();
Expand Down
5 changes: 2 additions & 3 deletions src/libmscore/layout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2735,8 +2735,7 @@ void Score::createBeams(LayoutContext& lc, Measure* measure)
if (!beamNoContinue(prevCR->beamMode())
&& !pm->lineBreak() && !pm->pageBreak() && !pm->sectionBreak()
&& lc.prevMeasure
&& prevCR->durationType().type() >= TDuration::DurationType::V_EIGHTH
&& prevCR->durationType().type() <= TDuration::DurationType::V_1024TH) {
&& !(prevCR->isChord() && prevCR->durationType().type() <= TDuration::DurationType::V_QUARTER)) {
beam = prevCR->beam();
//a1 = beam ? beam->elements().front() : prevCR;
a1 = beam ? nullptr : prevCR; // when beam is found, a1 is no longer required.
Expand Down Expand Up @@ -2801,7 +2800,7 @@ void Score::createBeams(LayoutContext& lc, Measure* measure)
bm = Beam::Mode::NONE;
}

if ((cr->durationType().type() <= TDuration::DurationType::V_QUARTER) || (bm == Beam::Mode::NONE)) {
if ((cr->isChord() && cr->durationType().type() <= TDuration::DurationType::V_QUARTER) || (bm == Beam::Mode::NONE)) {
bool removeBeam = true;
if (beam) {
beam->layout1();
Expand Down
1 change: 1 addition & 0 deletions src/libmscore/layoutbreak.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ class LayoutBreak final : public Element

LayoutBreak* clone() const override { return new LayoutBreak(*this); }
ElementType type() const override { return ElementType::LAYOUT_BREAK; }
int subtype() const override { return static_cast<int>(_layoutBreakType); }

void setLayoutBreakType(Type);
Type layoutBreakType() const { return _layoutBreakType; }
Expand Down
2 changes: 2 additions & 0 deletions src/libmscore/mscore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,8 @@ std::vector<MScoreError> MScore::errorList {
{ MsError::DEST_NO_CR, "p7", QT_TRANSLATE_NOOP("error", "Destination is not a chord or rest") },
{ MsError::CANNOT_CHANGE_LOCAL_TIMESIG, "l1",
QT_TRANSLATE_NOOP("error", "Cannot change local time signature:\nMeasure is not empty") },
{ MsError::CORRUPTED_MEASURE, "c1", QT_TRANSLATE_NOOP("error",
"Cannot change time signature in front of a corrupted measure") },
};

MsError MScore::_error { MsError::MS_NO_ERROR };
Expand Down
3 changes: 2 additions & 1 deletion src/libmscore/mscore.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//=============================================================================
//=============================================================================
// MuseScore
// Music Composition & Notation
//
Expand Down Expand Up @@ -264,6 +264,7 @@ enum class MsError {
NO_MIME,
DEST_NO_CR,
CANNOT_CHANGE_LOCAL_TIMESIG,
CORRUPTED_MEASURE,
};

/// \cond PLUGIN_API \private \endcond
Expand Down
21 changes: 16 additions & 5 deletions src/libmscore/range.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -355,16 +355,18 @@ void TrackList::read(const Segment* fs, const Segment* es)
// checkRest
//---------------------------------------------------------

static void checkRest(Fraction& rest, Measure*& m, const Fraction& d)
static bool checkRest(Fraction& rest, Measure*& m, const Fraction& d)
{
if (rest.isZero()) {
if (m->nextMeasure()) {
m = m->nextMeasure();
rest = m->ticks();
} else {
qFatal("premature end of measure list, rest %d/%d", d.numerator(), d.denominator());
qWarning("premature end of measure list, rest %d/%d", d.numerator(), d.denominator());
return false;
}
}
return true;
}

//---------------------------------------------------------
Expand Down Expand Up @@ -484,7 +486,10 @@ bool TrackList::write(Score* score, const Fraction& tick) const
for (Element* e : *this) {
if (e->isDurationElement()) {
Fraction duration = toDurationElement(e)->ticks();
checkRest(remains, m, duration); // go to next measure, if necessary
if (!checkRest(remains, m, duration)) { // go to next measure, if necessary
MScore::setError(MsError::CORRUPTED_MEASURE);
return false;
}
if (duration > remains && e->isTuplet()) {
// experimental: allow tuplet split in the middle
if (duration != remains * 2) {
Expand Down Expand Up @@ -516,7 +521,10 @@ bool TrackList::write(Score* score, const Fraction& tick) const
} else if (e->isChordRest()) {
Fraction du = qMin(remains, duration);
std::vector<TDuration> dl = toDurationList(du, e->isChord());
Q_ASSERT(!dl.empty());
if (dl.empty()) {
MScore::setError(MsError::CORRUPTED_MEASURE);
return false;
}
for (const TDuration& k : dl) {
segment = m->undoGetSegmentR(SegmentType::ChordRest, m->ticks() - remains);
ChordRest* cr = toChordRest(e->clone());
Expand Down Expand Up @@ -559,7 +567,10 @@ bool TrackList::write(Score* score, const Fraction& tick) const
}
firstpart = false;
if (duration > Fraction(0,1)) {
checkRest(remains, m, duration); // go to next measure, if necessary
if (!checkRest(remains, m, duration)) { // go to next measure, if necessary
MScore::setError(MsError::CORRUPTED_MEASURE);
return false;
}
}
}
} else if (e->isBarLine()) {
Expand Down
2 changes: 1 addition & 1 deletion src/libmscore/segment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1125,7 +1125,7 @@ bool Segment::hasElements(int minTrack, int maxTrack) const

bool Segment::allElementsInvisible() const
{
if (isType(SegmentType::BarLineType | SegmentType::ChordRest | SegmentType::Breath)) {
if (isType(SegmentType::BarLineType | SegmentType::ChordRest)) {
return false;
}

Expand Down
6 changes: 6 additions & 0 deletions src/libmscore/textbase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1856,6 +1856,12 @@ void TextBase::createLayout()
if (rows() <= cursor.row()) {
_layout.append(TextBlock());
}

if (cursor.row() < rows()) {
if (_layout[cursor.row()].fragments().size() == 0) {
_layout[cursor.row()].insertEmptyFragmentIfNeeded(&cursor); // an empty fragment may be needed on either side of the newline
}
}
} else {
if (symState) {
sym += c;
Expand Down
8 changes: 3 additions & 5 deletions src/libmscore/textedit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -571,13 +571,10 @@ void SplitJoinText::join(EditData* ed)
t->textBlock(line - 1).fragments().append(*fragmentsList);
delete fragmentsList;

int lines = t->rows();
if (line < lines) {
t->textBlock(line).setEol(eol);
}
t->textBlockList().removeAt(line);

c.setRow(line - 1);
c.curLine().setEol(eol);
c.setColumn(col);
c.setFormat(*charFmt); // restore orig. format at new line
c.clearSelection();
Expand All @@ -592,12 +589,13 @@ void SplitJoinText::split(EditData* ed)
{
TextBase* t = c.text();
int line = c.row();
bool eol = c.curLine().eol();
t->setTextInvalid();
t->triggerLayout();

CharFormat* charFmt = c.format(); // take current format
t->textBlockList().insert(line + 1, c.curLine().split(c.column(), t->cursorFromEditData(*ed)));
c.curLine().setEol(true);
c.curLine().setEol(eol);

c.setRow(line + 1);
c.curLine().setEol(true);
Expand Down
3 changes: 1 addition & 2 deletions vtest/scores/frametext.mscx
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,7 @@
<Text>
<size>12</size>
<align>right,center</align>
<text>rightCenter<font face=""></font>
</text>
<text>rightCenter<font face=""></font></text>
</Text>
<Text>
<size>12</size>
Expand Down