]> git.saurik.com Git - wxWidgets.git/commitdiff
Calling a virtual function from a destructor is not good:
authorMattia Barbon <mbarbon@cpan.org>
Wed, 26 Mar 2003 22:22:55 +0000 (22:22 +0000)
committerMattia Barbon <mbarbon@cpan.org>
Wed, 26 Mar 2003 22:22:55 +0000 (22:22 +0000)
rearranged code to avoid it.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@19826 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/motif/toplevel.h
src/motif/dialog.cpp
src/motif/frame.cpp
src/motif/toplevel.cpp

index 6d16717756ada716d22dd698a32a2e2a3824e698..61c26d82e8be8b17c06f7d5b3405662a37f8967c 100644 (file)
@@ -60,6 +60,8 @@ public:
 protected:
     // common part of all constructors
     void Init();
+    // common part of wxDialog/wxFrame destructors
+    void PreDestroy();
 
 private:
     // both these functions should be pure virtual
index def4c93d14be26d1b92caf0857ef79f4fd9e686c..ab5c7eecccb02f5f792a5230385a0a03ca690db9 100644 (file)
@@ -208,6 +208,7 @@ void wxDialog::SetModal(bool flag)
 wxDialog::~wxDialog()
 {
     m_isBeingDeleted = TRUE;
+
     delete m_eventLoop;
 
     if (m_mainWidget)
@@ -221,6 +222,9 @@ wxDialog::~wxDialog()
     {
         XtUnmapWidget((Widget) m_mainWidget);
     }
+
+    PreDestroy();
+    DoDestroy();
 }
 
 void wxDialog::DoDestroy()
index 18dc34e554286a5fca291f671c6e7793032f14d7..978b6e62003c2d3914dd992b7d8dd67c62834deb 100644 (file)
@@ -310,15 +310,19 @@ wxFrame::~wxFrame()
         delete m_frameStatusBar;
         m_frameStatusBar = NULL;
     }
+
+    PreDestroy();
+    DoDestroy();
 }
 
 void wxFrame::DoDestroy()
 {
     Widget frameShell = (Widget)GetShellWidget();
 
-    XtRemoveEventHandler( frameShell, StructureNotifyMask,
-                          False, (XtEventHandler)wxFrameMapProc,
-                          (XtPointer)this );
+    if( frameShell )
+        XtRemoveEventHandler( frameShell, StructureNotifyMask,
+                              False, (XtEventHandler)wxFrameMapProc,
+                              (XtPointer)this );
 
     if( m_clientArea )
     {
index 6d1b385573c2aa5829bf09bce1951da83c748b77..031a3c23dd4970059678c0156c87de83a5d9e482 100644 (file)
@@ -64,7 +64,7 @@ static void wxTLWEventHandler( Widget wid,
 // wxTopLevelWindowMotif implementation
 // ===========================================================================
 
-wxTopLevelWindowMotif::~wxTopLevelWindowMotif()
+void wxTopLevelWindowMotif::PreDestroy()
 {
     wxTopLevelWindows.DeleteObject(this);
 
@@ -85,9 +85,10 @@ wxTopLevelWindowMotif::~wxTopLevelWindowMotif()
                               wxTLWEventHandler,
                               (XtPointer)this );
     }
+}
 
-    DoDestroy();
-
+wxTopLevelWindowMotif::~wxTopLevelWindowMotif()
+{
     SetMainWidget( (WXWidget)0 );
 
     // If this is the last top-level window, exit.