Vincent R.
2014-07-30 08:50:32 UTC
Hi,
I am working on a new project that uses wxWidgets 2.8 framework and when I
read some code I didn't write I am wondering if it's the right thing to do.
So inside this project controls are allocated using new and deleted inside
the MainFrame destructor :
MainAppFrame::MainAppFrame(wxWindow *parent,
wxString & i_sAppNAme,
const wxString & strDeviceName,
wxWindowID id,
const wxString& title,
const wxPoint& pos,
const wxSize& size
) : MainXXXXAppFrame(parent,
i_sAppNAme,strDeviceName,"",id,title,pos,size)
{
//Controls are allocated here
m_DirectDrivePanel = new DirectDrivePanel(this); // DirectDrivePanel
inheriths from wxPanel
...
}
MainAppFrame::~MainAppFrame()
{
if (DirectDrivePanel != NULL)
delete DirectDrivePanel ;
}
deallocation ?
To me when I quit application I should see some crashes because object is
manually deleted , then when the frame is destroyed it should delete a
dangling pointer but this is not
what I can see. Manually deleting the control seems to work...
I am working on a new project that uses wxWidgets 2.8 framework and when I
read some code I didn't write I am wondering if it's the right thing to do.
So inside this project controls are allocated using new and deleted inside
the MainFrame destructor :
MainAppFrame::MainAppFrame(wxWindow *parent,
wxString & i_sAppNAme,
const wxString & strDeviceName,
wxWindowID id,
const wxString& title,
const wxPoint& pos,
const wxSize& size
) : MainXXXXAppFrame(parent,
i_sAppNAme,strDeviceName,"",id,title,pos,size)
{
//Controls are allocated here
m_DirectDrivePanel = new DirectDrivePanel(this); // DirectDrivePanel
inheriths from wxPanel
...
}
MainAppFrame::~MainAppFrame()
{
if (DirectDrivePanel != NULL)
delete DirectDrivePanel ;
}
From what I know normally wxWidgets object are released by the parents, so
I am wondering why the following code works and it doesn't make a doubledeallocation ?
To me when I quit application I should see some crashes because object is
manually deleted , then when the frame is destroyed it should delete a
dangling pointer but this is not
what I can see. Manually deleting the control seems to work...
--
Please read http://www.wxwidgets.org/support/mlhowto.htm before posting.
To unsubscribe, send email to wx-users+***@googlegroups.com
or visit http://groups.google.com/group/wx-users
Please read http://www.wxwidgets.org/support/mlhowto.htm before posting.
To unsubscribe, send email to wx-users+***@googlegroups.com
or visit http://groups.google.com/group/wx-users