Opened 6 months ago

Closed 6 months ago

#15909 closed defect (fixed)

Memory leak. wxRibbonButtonBar::DeleteButton(id) doesn't delete button object

Reported by: tan Owned by:
Priority: normal Milestone: 3.0.1
Component: GUI-generic Version: dev-latest
Keywords: wxRibbonButtonBar memory leak Cc:
Blocked By: Blocking:
Patch: yes

Description

It is unexpected behaviour and it leads to memory leaks.
Do it in wxRibbonButtonBar::DeleteButton(id)is consistent with the behaviour of the wxRibbonButtonBar::ClearButtons().
Patch is attached.

Attachments (3)

buttonbar.cpp.patch download (338 bytes) - added by tan 6 months ago.
buttonbar_1.cpp.patch download (412 bytes) - added by tan 6 months ago.
buttonbar_2.cpp.patch download (563 bytes) - added by tan 6 months ago.

Download all attachments as: .zip

Change History (7)

Changed 6 months ago by tan

comment:1 Changed 6 months ago by VZ

  • Resolution set to fixed
  • Status changed from new to closed

(In [75710]) Delete the button object in wxRibbonButtonBar::DeleteButton().

Unlike ClearButtons(), DeleteButton() didn't actually delete the button.

Fix this and document this behaviour.

Closes #15909.

Changed 6 months ago by tan

comment:2 Changed 6 months ago by tan

  • Resolution fixed deleted
  • Status changed from closed to reopened

Reset to NULL cached pointers (m_active_button and m_hovered_button). They may point to deleted button object.

Changed 6 months ago by tan

comment:3 Changed 6 months ago by tan

Do it in less destructive manner. Check before if it is really needed.

comment:4 Changed 6 months ago by VZ

  • Resolution set to fixed
  • Status changed from reopened to closed

(In [75714]) Don't keep dangling pointers in other wxRibbonButtonBar members neither.

This should have been part of r75710: after deleting the button, also reset
any stored pointers to it.

Closes #15909.

Note: See TracTickets for help on using tickets.