-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3564 from dmitrio95/bugfix/flute_0_crash
fix #222031: remove ties and spanners when removing induvidual notes within a chord
- Loading branch information
Showing
4 changed files
with
62 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -579,6 +579,26 @@ const char* AddElement::name() const | |
return buffer; | ||
} | ||
|
||
//--------------------------------------------------------- | ||
// removeNote | ||
// Helper function for RemoveElement class | ||
//--------------------------------------------------------- | ||
|
||
static void removeNote(const Note* note) | ||
{ | ||
Score* score = note->score(); | ||
if (note->tieFor() && note->tieFor()->endNote()) | ||
score->undo(new RemoveElement(note->tieFor())); | ||
if (note->tieBack()) | ||
score->undo(new RemoveElement(note->tieBack())); | ||
for (Spanner* s : note->spannerBack()) { | ||
score->undo(new RemoveElement(s)); | ||
} | ||
for (Spanner* s : note->spannerFor()) { | ||
score->undo(new RemoveElement(s)); | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
lasconic
Contributor
|
||
} | ||
} | ||
|
||
//--------------------------------------------------------- | ||
// RemoveElement | ||
//--------------------------------------------------------- | ||
|
@@ -601,19 +621,15 @@ RemoveElement::RemoveElement(Element* e) | |
score->undo(new RemoveElement(tremolo)); | ||
} | ||
for (const Note* note : chord->notes()) { | ||
if (note->tieFor() && note->tieFor()->endNote()) | ||
score->undo(new RemoveElement(note->tieFor())); | ||
if (note->tieBack()) | ||
score->undo(new RemoveElement(note->tieBack())); | ||
for (Spanner* s : note->spannerBack()) { | ||
score->undo(new RemoveElement(s)); | ||
} | ||
for (Spanner* s : note->spannerFor()) { | ||
score->undo(new RemoveElement(s)); | ||
} | ||
removeNote(note); | ||
} | ||
} | ||
} | ||
else if (element->isNote()) { | ||
// Removing an individual note within a chord | ||
const Note* note = toNote(element); | ||
removeNote(note); | ||
} | ||
} | ||
|
||
//--------------------------------------------------------- | ||
|
@@ -640,10 +656,7 @@ void RemoveElement::undo(EditData*) | |
if (element->isChord()) { | ||
Chord* chord = toChord(element); | ||
for (Note* note : chord->notes()) { | ||
if (note->tieBack()) | ||
note->tieBack()->setEndNote(note); | ||
if (note->tieFor() && note->tieFor()->endNote()) | ||
note->tieFor()->endNote()->setTieBack(note->tieFor()); | ||
note->connectTiedNotes(); | ||
} | ||
} | ||
undoAddTuplet(toChordRest(element)); | ||
|
@@ -667,9 +680,7 @@ void RemoveElement::redo(EditData*) | |
if (element->isChord()) { | ||
Chord* chord = toChord(element); | ||
for (Note* note : chord->notes()) { | ||
if (note->tieFor() && note->tieFor()->endNote()) { | ||
note->tieFor()->endNote()->setTieBack(0); | ||
} | ||
note->disconnectTiedNotes(); | ||
} | ||
} | ||
} | ||
|
Is this Dynamic allocation?? (because of 'new')
If it is, why don't you use 'delete'??