Calling a virtual function from a destructor is not good:
rearranged code to avoid it. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@19826 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -60,6 +60,8 @@ public:
|
|||||||
protected:
|
protected:
|
||||||
// common part of all constructors
|
// common part of all constructors
|
||||||
void Init();
|
void Init();
|
||||||
|
// common part of wxDialog/wxFrame destructors
|
||||||
|
void PreDestroy();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// both these functions should be pure virtual
|
// both these functions should be pure virtual
|
||||||
|
@@ -208,6 +208,7 @@ void wxDialog::SetModal(bool flag)
|
|||||||
wxDialog::~wxDialog()
|
wxDialog::~wxDialog()
|
||||||
{
|
{
|
||||||
m_isBeingDeleted = TRUE;
|
m_isBeingDeleted = TRUE;
|
||||||
|
|
||||||
delete m_eventLoop;
|
delete m_eventLoop;
|
||||||
|
|
||||||
if (m_mainWidget)
|
if (m_mainWidget)
|
||||||
@@ -221,6 +222,9 @@ wxDialog::~wxDialog()
|
|||||||
{
|
{
|
||||||
XtUnmapWidget((Widget) m_mainWidget);
|
XtUnmapWidget((Widget) m_mainWidget);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PreDestroy();
|
||||||
|
DoDestroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxDialog::DoDestroy()
|
void wxDialog::DoDestroy()
|
||||||
|
@@ -310,15 +310,19 @@ wxFrame::~wxFrame()
|
|||||||
delete m_frameStatusBar;
|
delete m_frameStatusBar;
|
||||||
m_frameStatusBar = NULL;
|
m_frameStatusBar = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PreDestroy();
|
||||||
|
DoDestroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxFrame::DoDestroy()
|
void wxFrame::DoDestroy()
|
||||||
{
|
{
|
||||||
Widget frameShell = (Widget)GetShellWidget();
|
Widget frameShell = (Widget)GetShellWidget();
|
||||||
|
|
||||||
XtRemoveEventHandler( frameShell, StructureNotifyMask,
|
if( frameShell )
|
||||||
False, (XtEventHandler)wxFrameMapProc,
|
XtRemoveEventHandler( frameShell, StructureNotifyMask,
|
||||||
(XtPointer)this );
|
False, (XtEventHandler)wxFrameMapProc,
|
||||||
|
(XtPointer)this );
|
||||||
|
|
||||||
if( m_clientArea )
|
if( m_clientArea )
|
||||||
{
|
{
|
||||||
|
@@ -64,7 +64,7 @@ static void wxTLWEventHandler( Widget wid,
|
|||||||
// wxTopLevelWindowMotif implementation
|
// wxTopLevelWindowMotif implementation
|
||||||
// ===========================================================================
|
// ===========================================================================
|
||||||
|
|
||||||
wxTopLevelWindowMotif::~wxTopLevelWindowMotif()
|
void wxTopLevelWindowMotif::PreDestroy()
|
||||||
{
|
{
|
||||||
wxTopLevelWindows.DeleteObject(this);
|
wxTopLevelWindows.DeleteObject(this);
|
||||||
|
|
||||||
@@ -85,9 +85,10 @@ wxTopLevelWindowMotif::~wxTopLevelWindowMotif()
|
|||||||
wxTLWEventHandler,
|
wxTLWEventHandler,
|
||||||
(XtPointer)this );
|
(XtPointer)this );
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
DoDestroy();
|
wxTopLevelWindowMotif::~wxTopLevelWindowMotif()
|
||||||
|
{
|
||||||
SetMainWidget( (WXWidget)0 );
|
SetMainWidget( (WXWidget)0 );
|
||||||
|
|
||||||
// If this is the last top-level window, exit.
|
// If this is the last top-level window, exit.
|
||||||
|
Reference in New Issue
Block a user