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

fix #175216, fix #269114: Crash with shortcut alt+arrow up/down if mo… #3449

Closed
wants to merge 1 commit into from

Conversation

mattmcclinch
Copy link
Contributor

…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

…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));
Copy link
Contributor Author

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) {
Copy link
Contributor Author

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) {
Copy link
Contributor Author

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()) {
Copy link
Contributor Author

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;
Copy link
Contributor

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.

@lasconic
Copy link
Contributor

lasconic commented Feb 9, 2018

Fixed the NULL -> nullptr and merged manually in 2e112ab

@lasconic lasconic closed this Feb 9, 2018
@mattmcclinch mattmcclinch deleted the up-down-chord branch September 5, 2018 13:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants