-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
fix #175216, fix #269114: Crash with shortcut alt+arrow up/down if mo… #3449
Conversation
…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
@@ -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)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Casting to a Note before checking that the Element is a Note causes a crash.
if (el && (el->isNote() || el->isRest())) | ||
cmdGotoElement(score()->upAlt(el)); | ||
el = score()->selection().element(); | ||
while (el->isRest() && toRest(el)->isGap() && el->voice() != 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dereferencing el before making sure that it is not NULL causes a crash. Also, gaps in voice 1 should not be possible. But if there were a gap in voice 1, still handle it correctly.
@@ -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) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Making sure that el->voice() != 3
defeats the purpose of the following few lines, which correctly terminate the while loop.
@@ -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()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This causes Alt+up to do nothing if the bottom note of the chord is selected.
&& ((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) : NULL; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We prefer nullptr than NULL.
Fixed the NULL -> nullptr and merged manually in 2e112ab |
…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