mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-12 09:36:33 +01:00
amend 365e3ef8e2 to be "more right"
NoteBase-derived note objects must delete their children, because often they are deleted long before the parent (group) is. However, in MidiView::clear_events() we used to call _note_group->clear (true) first, which would delete the canvas items owned by these objects, without them knowing about it. This made it dangerous for them to delete those same items in their destructors. This reverses the ordering so that NoteBase objects are deleted first (along with their canvas items) and after that we clear _note_group which will address any danging canvas items created there that are not owned by a NoteBase-derived object
This commit is contained in:
parent
ca96e004bf
commit
8b389ee829
4 changed files with 7 additions and 10 deletions
|
|
@ -40,9 +40,7 @@ Hit::Hit (MidiView& region, Item* parent, double size, const std::shared_ptr<Not
|
|||
|
||||
Hit::~Hit ()
|
||||
{
|
||||
/* do not delete the visual note here, because that will be handled by
|
||||
* the parent
|
||||
*/
|
||||
delete _polygon;
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
|||
|
|
@ -876,12 +876,13 @@ MidiView::clear_events ()
|
|||
// clear selection without signaling or trying to change state of event objects
|
||||
_selection.clear ();
|
||||
clear_ghost_events ();
|
||||
/* This will delete all the _visual_note members of the NoteBase* elements in the _events map */
|
||||
_note_group->clear (true);
|
||||
/* The above did not actually delete the the NoteBase* elements, so do that now */
|
||||
for (auto & [model_note,gui_note] : _events) {
|
||||
delete gui_note;
|
||||
}
|
||||
/* This will delete any danging canvas items that were not owned by the
|
||||
* NoteBase objects we just deleted.
|
||||
*/
|
||||
_note_group->clear (true);
|
||||
_events.clear();
|
||||
_patch_changes.clear();
|
||||
_sys_exes.clear();
|
||||
|
|
|
|||
|
|
@ -39,9 +39,7 @@ Note::Note (MidiView& region, ArdourCanvas::Item* parent, const std::shared_ptr<
|
|||
|
||||
Note::~Note ()
|
||||
{
|
||||
/* do not delete the canvas item here, because that will be handled by
|
||||
* the parent
|
||||
*/
|
||||
delete _visual_note;
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
|||
|
|
@ -88,7 +88,7 @@ NoteBase::NoteBase(MidiView& v, bool with_events, const std::shared_ptr<NoteType
|
|||
NoteBase::~NoteBase()
|
||||
{
|
||||
_view.note_deleted (this);
|
||||
/* do not delete _text, parent will do so */
|
||||
delete _text;
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue