Skip to content

Commit

Permalink
fix #175216, fix #269114: Crash with shortcut alt+arrow up/down if mo…
Browse files Browse the repository at this point in the history
…re than one element or nothing is selected

Fix other related issues with the up-chord/down-chord commands
Prevent crash when adjusting the grips of ties
  • Loading branch information
mattmcclinch authored and lasconic committed Feb 9, 2018
1 parent 06cc782 commit 2e112ab
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 10 deletions.
7 changes: 3 additions & 4 deletions libmscore/navigate.cpp
Expand Up @@ -197,10 +197,9 @@ Element* Score::upAlt(Element* element)
Chord* chord = note->chord();
const std::vector<Note*>& notes = chord->notes();
auto i = std::find(notes.begin(), notes.end(), note);
if (i != notes.begin()) {
++i;
re = i != notes.end() ? *i : 0;
}
++i;
if (i != notes.end())
re = *i;
else {
re = prevTrack(chord);
if (re->track() == chord->track())
Expand Down
7 changes: 3 additions & 4 deletions libmscore/tie.cpp
Expand Up @@ -153,10 +153,9 @@ void TieSegment::editDrag(EditData& ed)
//
if ((g == Grip::START && isSingleBeginType()) || (g == Grip::END && isSingleEndType())) {
Spanner* spanner = tie();
Note* note = toNote(ed.view->elementNear(ed.pos));
if (note && note->isNote()
&& ((g == Grip::END && note->tick() > tie()->tick()) || (g == Grip::START && note->tick() < tie()->tick2()))
) {
Element* e = ed.view->elementNear(ed.pos);
Note* note = (e && e->isNote()) ? toNote(e) : nullptr;
if (note && ((g == Grip::END && note->tick() > tie()->tick()) || (g == Grip::START && note->tick() < tie()->tick2()))) {
if (g == Grip::END) {
Tie* tie = toTie(spanner);
if (tie->startNote()->pitch() == note->pitch()
Expand Down
9 changes: 7 additions & 2 deletions mscore/scoreview.cpp
Expand Up @@ -1904,10 +1904,15 @@ void ScoreView::cmd(const char* s)
}
else if (cmd == "up-chord") {
Element* el = score()->selection().element();
Element* oel = el;
if (el && (el->isNote() || el->isRest()))
cmdGotoElement(score()->upAlt(el));
el = score()->selection().element();
while (el->isRest() && toRest(el)->isGap() && el->voice() != 0) {
while (el && el->isRest() && toRest(el)->isGap()) {
if (score()->upAlt(el) == el) {
cmdGotoElement(oel);
break;
}
el = score()->upAlt(el);
cmdGotoElement(el);
}
Expand All @@ -1918,7 +1923,7 @@ void ScoreView::cmd(const char* s)
if (el && (el->isNote() || el->isRest()))
cmdGotoElement(score()->downAlt(el));
el = score()->selection().element();
while (el->isRest() && toRest(el)->isGap() && el->voice() != 3) {
while (el && el->isRest() && toRest(el)->isGap()) {
if (score()->downAlt(el) == el) {
cmdGotoElement(oel);
break;
Expand Down

0 comments on commit 2e112ab

Please sign in to comment.