wxSmith creates common dialogs in the heap but does not destroy them, leading to memory leaks and hangs on exit. In fact, wxsmith creates this code in the frame's destructor:
//(*Destroy(TestFrame) //*)
but never writes inside it.
Discussion initiated in the forum. Some say common dialogs should not be in wxSmith, but if they are they should be destroyed properly.
http://forums.codeblocks.org/index.php/topic,23324.0.html
This patch fixes the issue. wxPageSetupDialog and wxPrintDialog are deleted, the rest are destroyed.
EDIT: patch deleted on 2021/05/06
Last edit: Miguel Gimenez 2021-05-06
While testing I discovered that the code generated for wxRichtextStyleOrganiserDialog does not compile because it needs wx/dialog.h to be included before wx/richtext/richtextstyledlg.h. I think this is a wxWidgets issue, but while they fix it we need a workaround,
This second patch fixes this, and must be applied after the one above.
EDIT: ticket created in wxWidgets site.
EDIT2: fixed in wx3.0 and wx3.1 branches, but this patch is needed anyway
EDIT3: patch deleted on 2021/05/06
Last edit: Miguel Gimenez 2021-05-06
I have updated the patch and divided it in two parts.
The first part (wxsmith3a.patch) adds the infrastructure needed for inserting code automatically in window destructors, namely variable m_DestroyingCode holding the code to be inserted and AddDestroyingCode() method for appending code to it.
The second part (wxsmith3b.patch) adds destroying code for the following common dialogs:
ColourDialog
DirDialog
FileDialog
FindReplaceDialog
FontDialog
MessageDialog
MultiChoiceDialog
PageSetupdialog
PasswordEntryDialog
PrintDialog
RichtextFormattingDialog
RichtextStyleOrganiserDialog
SingleChoiceDialog
SymbolPickerDialog
* TextEntryDialog
As said in the original post, the added code prevents application locking when deleting the object that owns some of the dialogs listed above. Other dialogs do not lock the application, but may have other secondary effects.
Last edit: Miguel Gimenez 2021-05-06
Applied, but I've decided to combine the patches. Thanks.