Fix memory leaks in artprov sample

The list control used in the Resources Browser dialog had
dynamically allocated wxStrings assigned as item data that
were never freed.

Closes #22070.
This commit is contained in:
PB 2022-01-28 21:35:06 +01:00 committed by Vadim Zeitlin
parent 085d15015a
commit 754f75c1cd
2 changed files with 9 additions and 0 deletions

View File

@ -192,6 +192,14 @@ wxArtBrowserDialog::wxArtBrowserDialog(wxWindow *parent)
SetArtClient(wxART_MESSAGE_BOX);
}
wxArtBrowserDialog::~wxArtBrowserDialog()
{
const int itemCount = m_list->GetItemCount();
// item data are set by the ART_ICON macro
for ( int i = 0; i < itemCount; ++i )
delete reinterpret_cast<wxString*>(m_list->GetItemData(i));
}
wxSize wxArtBrowserDialog::GetSelectedBitmapSize() const
{

View File

@ -22,6 +22,7 @@ class wxArtBrowserDialog : public wxDialog
{
public:
wxArtBrowserDialog(wxWindow *parent);
~wxArtBrowserDialog();
void SetArtClient(const wxArtClient& client);
void SetArtBitmap(const wxArtID& id, const wxArtClient& client, const wxSize& size = wxDefaultSize);