avoid memory leak (and GUI object leak)
This commit is contained in:
parent
70b41d10b1
commit
9f14eea88a
@ -1560,9 +1560,18 @@ MidiView::apply_note_range (uint8_t min, uint8_t max, bool force)
|
|||||||
void
|
void
|
||||||
MidiView::begin_write()
|
MidiView::begin_write()
|
||||||
{
|
{
|
||||||
if (_active_notes) {
|
/* delete any lingering active notes, just in case.
|
||||||
delete [] _active_notes;
|
|
||||||
|
XXX this should not happen.
|
||||||
|
*/
|
||||||
|
|
||||||
|
for (unsigned i = 0; i < 128; ++i) {
|
||||||
|
delete _active_notes[i];
|
||||||
}
|
}
|
||||||
|
delete [] _active_notes;
|
||||||
|
|
||||||
|
/* reallocate */
|
||||||
|
|
||||||
_active_notes = new Note*[128];
|
_active_notes = new Note*[128];
|
||||||
for (unsigned i = 0; i < 128; ++i) {
|
for (unsigned i = 0; i < 128; ++i) {
|
||||||
_active_notes[i] = nullptr;
|
_active_notes[i] = nullptr;
|
||||||
@ -1576,7 +1585,12 @@ MidiView::begin_write()
|
|||||||
void
|
void
|
||||||
MidiView::end_write()
|
MidiView::end_write()
|
||||||
{
|
{
|
||||||
|
for (unsigned i = 0; i < 128; ++i) {
|
||||||
|
delete _active_notes[i];
|
||||||
|
}
|
||||||
|
|
||||||
delete [] _active_notes;
|
delete [] _active_notes;
|
||||||
|
|
||||||
_active_notes = nullptr;
|
_active_notes = nullptr;
|
||||||
_marked_for_selection.clear();
|
_marked_for_selection.clear();
|
||||||
_marked_for_velocity.clear();
|
_marked_for_velocity.clear();
|
||||||
|
Loading…
Reference in New Issue
Block a user