Developer forums (C::B DEVELOPMENT STRICTLY!) > Plugins development

Program hangs on exit when using wxMultiChoiceDialog with wxSmith

(1/2) > >>

Miguel Gimenez:
I have used common dialogs with wxSmith before without any problem, but today I have used wxMultiChoiceDialog and the program hanged on exit.

Checking the dialog flow I have noticed that the common dialogs (FileDialog, DirDialog...) are created by wxSmith but they are never destroyed. Adding a call to wxMultiChoiceDialog->Destroy() in the main frame destructor solves the hang issue.

I think wxSmith should call Destroy() of the common dialogs it creates, otherwise we are exposed to hangs and memory leaks.

ollydbg:
How do you use the dialog? Does wxsmith generate the creating code of a dialog?
For me, I just use wxsmith to generate a dialog header file and implementation file, and all the creating and destroying code are added manually by hand.

Miguel Gimenez:
If you have a frame (generated with wxSmith) and add a wxMultiChoiceDialog to the frame (using wxSmith again) you end with this:

Frame constructor (some code removed for clarity)


--- Code: ---    //(*Initialize(FichaFrame)
    Create(parent, wxID_ANY, _("Test"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_FRAME_STYLE, "wxID_ANY");
    wxString __wxMultiChoiceDialogChoices_1[3] =
    {
        _("PDF"),
        _("CSV"),
        _("HTML")
    };

    MultiChoiceDialog1 = new wxMultiChoiceDialog(this, _("A"), _("B"), 3, __wxMultiChoiceDialogChoices_1, wxCHOICEDLG_STYLE|wxOK|wxCANCEL|wxCENTRE, wxDefaultPosition);
    //*)

--- End code ---

Frame destructor


--- Code: ---    //(*Destroy(FichaFrame)
    //*)

--- End code ---

The wxSmith code in the frame destructor should be


--- Code: ---    //(*Destroy(FichaFrame)
    MultiChoiceDialog1->Destroy();
    //*)

--- End code ---

THe lack of destruction is OK for things like wxButtons and the such, as they are owned and destroyed by containers, but not for common dialogs. FileDialog, DirDialog and others suffer the same problem.

I have been looking in wxSmith's code and there is no provision for filling the destructor part (something like OnBuildDestroyingCode()).

oBFusCATed:
But this usage of these dialogs isn't really good. They are meant to be used locally and to have very little scope. I don't think it is a job of wxSmith to manage these dialogs.

BlueHazzard:

--- Quote ---Code:

    //(*Destroy(FichaFrame)
    //*)


The wxSmith code in the frame destructor should be

Code:

    //(*Destroy(FichaFrame)
    MultiChoiceDialog1->Destroy();
    //*)

--- End quote ---

the code to construct this is in the pipeline :) (if this is the correct way to use the dialog is a other question that i can not answer

Navigation

[0] Message Index

[#] Next page

Go to full version