From b0ee47ff76c278c053ac2ad36bb3129b0fcd050f Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Tue, 14 Aug 2001 14:59:44 +0000 Subject: [PATCH] 1. reset default item in ~wxWindow (better to be safe) 2. blind fix for Motif compilation git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@11377 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/motif/control.h | 2 -- src/common/wincmn.cpp | 6 ++++++ src/motif/button.cpp | 3 +-- src/motif/control.cpp | 8 -------- 4 files changed, 7 insertions(+), 12 deletions(-) diff --git a/include/wx/motif/control.h b/include/wx/motif/control.h index e6f8a9acca..d164e52485 100644 --- a/include/wx/motif/control.h +++ b/include/wx/motif/control.h @@ -46,8 +46,6 @@ public: const wxValidator& validator = wxDefaultValidator, const wxString& name = wxControlNameStr); - ~wxControl(); - // simulates the event, returns TRUE if the event was processed virtual void Command(wxCommandEvent& WXUNUSED(event)) { } diff --git a/src/common/wincmn.cpp b/src/common/wincmn.cpp index 4c5ebcc5da..f71daad3b5 100644 --- a/src/common/wincmn.cpp +++ b/src/common/wincmn.cpp @@ -268,6 +268,12 @@ wxWindowBase::~wxWindowBase() if ( m_tooltip ) delete m_tooltip; #endif // wxUSE_TOOLTIPS + + // reset the dangling pointer our parent window may keep to us + if ( m_parent && m_parent->GetDefaultItem() == this ) + { + m_parent->SetDefaultItem(NULL); + } } bool wxWindowBase::Destroy() diff --git a/src/motif/button.cpp b/src/motif/button.cpp index f9a139b068..5aacdf44ae 100644 --- a/src/motif/button.cpp +++ b/src/motif/button.cpp @@ -110,8 +110,7 @@ bool wxButton::Create(wxWindow *parent, wxWindowID id, const wxString& label, void wxButton::SetDefault() { wxWindow *parent = GetParent(); - wxPanel *panel = wxDynamicCast(parent, wxPanel); - if ( panel ) + if ( parent ) panel->SetDefaultItem(this); // We initially do not set XmNdefaultShadowThickness, to have small buttons. diff --git a/src/motif/control.cpp b/src/motif/control.cpp index 6413b92103..894198a0a1 100644 --- a/src/motif/control.cpp +++ b/src/motif/control.cpp @@ -62,14 +62,6 @@ bool wxControl::Create( wxWindow *parent, return ret; } -wxControl::~wxControl() -{ - // If we delete an item, we should initialize the parent panel, - // because it could now be invalid. - if ( GetParent()->panel->GetDefaultItem() == this) - panel->SetDefaultItem(NULL); -} - void wxControl::SetLabel(const wxString& label) { Widget widget = (Widget) GetLabelWidget() ; -- 2.45.2