set m_isBeingDeleted to true (only) in SendDestroyEvent(); call it as early as possible during the window destruction to ensure that destroy event handlers can still access the full window object
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@58246 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -35,7 +35,6 @@ public:
|
||||
const wxValidator& validator = wxDefaultValidator,
|
||||
const wxString& name = wxControlNameStr);
|
||||
|
||||
virtual ~wxControl();
|
||||
|
||||
// Simulates an event
|
||||
virtual void Command(wxCommandEvent& event) { ProcessCommand(event); }
|
||||
|
@@ -32,7 +32,6 @@ public:
|
||||
{
|
||||
Create( pParent, vId, rPos, rSize, lStyle, rValidator, rsName );
|
||||
}
|
||||
virtual ~wxControl();
|
||||
|
||||
bool Create( wxWindow* pParent
|
||||
,wxWindowID vId
|
||||
|
@@ -35,7 +35,6 @@ public:
|
||||
const wxSize& size = wxDefaultSize, long style = 0,
|
||||
const wxValidator& validator = wxDefaultValidator,
|
||||
const wxString& name = wxControlNameStr);
|
||||
virtual ~wxControl();
|
||||
|
||||
// Simulates an event
|
||||
virtual void Command(wxCommandEvent& event) { ProcessCommand(event); }
|
||||
|
@@ -1402,7 +1402,8 @@ protected:
|
||||
void SatisfyConstraints();
|
||||
#endif // wxUSE_CONSTRAINTS
|
||||
|
||||
// Send the wxWindowDestroyEvent
|
||||
// Send the wxWindowDestroyEvent if not done yet and sets m_isBeingDeleted
|
||||
// to true
|
||||
void SendDestroyEvent();
|
||||
|
||||
// returns the main window of composite control; this is the window
|
||||
|
@@ -2898,7 +2898,7 @@ void wxAuiNotebook::InitNotebook(long style)
|
||||
wxAuiNotebook::~wxAuiNotebook()
|
||||
{
|
||||
// Indicate we're deleting pages
|
||||
m_isBeingDeleted = true;
|
||||
SendDestroyEvent();
|
||||
|
||||
while ( GetPageCount() > 0 )
|
||||
DeletePage(0);
|
||||
|
@@ -943,7 +943,6 @@ void wxWindowCocoa::Init()
|
||||
m_cocoaNSView = NULL;
|
||||
m_cocoaHider = NULL;
|
||||
m_wxCocoaScrollView = NULL;
|
||||
m_isBeingDeleted = false;
|
||||
m_isInPaint = false;
|
||||
m_visibleTrackingRectManager = NULL;
|
||||
}
|
||||
|
@@ -209,7 +209,9 @@ wxWindowBase::wxWindowBase()
|
||||
// Whether we're using the current theme for this window (wxGTK only for now)
|
||||
m_themeEnabled = false;
|
||||
|
||||
// VZ: this one shouldn't exist...
|
||||
// This is set to true by SendDestroyEvent() which should be called by the
|
||||
// most derived class to ensure that the destruction event is sent as soon
|
||||
// as possible to allow its handlers to still see the undestroyed window
|
||||
m_isBeingDeleted = false;
|
||||
|
||||
m_freezeCount = 0;
|
||||
@@ -387,6 +389,16 @@ bool wxWindowBase::IsBeingDeleted() const
|
||||
|
||||
void wxWindowBase::SendDestroyEvent()
|
||||
{
|
||||
if ( m_isBeingDeleted )
|
||||
{
|
||||
// we could have been already called from a more derived class dtor,
|
||||
// e.g. ~wxTLW calls us and so does ~wxWindow and the latter call
|
||||
// should be simply ignored
|
||||
return;
|
||||
}
|
||||
|
||||
m_isBeingDeleted = true;
|
||||
|
||||
wxWindowDestroyEvent event;
|
||||
event.SetEventObject(this);
|
||||
event.SetId(GetId());
|
||||
|
@@ -153,7 +153,7 @@ bool wxNonOwnedWindow::Create(wxWindow *parent,
|
||||
|
||||
wxNonOwnedWindow::~wxNonOwnedWindow()
|
||||
{
|
||||
m_isBeingDeleted = true;
|
||||
SendDestroyEvent();
|
||||
|
||||
// destroy all children before we destroy the underlying DirectFB window,
|
||||
// so that if any of them does something with the TLW, it will still work:
|
||||
|
@@ -88,8 +88,6 @@ wxWindowDFB::~wxWindowDFB()
|
||||
{
|
||||
SendDestroyEvent();
|
||||
|
||||
m_isBeingDeleted = true;
|
||||
|
||||
if ( gs_mouseCapture == this )
|
||||
ReleaseMouse();
|
||||
|
||||
|
@@ -85,8 +85,6 @@ bool wxDialog::Show( bool show )
|
||||
|
||||
wxDialog::~wxDialog()
|
||||
{
|
||||
m_isBeingDeleted = true;
|
||||
|
||||
// if the dialog is modal, this will end its event loop
|
||||
if ( IsModal() )
|
||||
EndModal(wxID_CANCEL);
|
||||
|
@@ -56,7 +56,8 @@ bool wxFrame::Create( wxWindow *parent,
|
||||
|
||||
wxFrame::~wxFrame()
|
||||
{
|
||||
m_isBeingDeleted = true;
|
||||
SendDestroyEvent();
|
||||
|
||||
DeleteAllBars();
|
||||
}
|
||||
|
||||
|
@@ -665,7 +665,7 @@ wxTopLevelWindowGTK::~wxTopLevelWindowGTK()
|
||||
RemoveGrab();
|
||||
}
|
||||
|
||||
m_isBeingDeleted = true;
|
||||
SendDestroyEvent();
|
||||
|
||||
// it may also be GtkScrolledWindow in the case of an MDI child
|
||||
if (GTK_IS_WINDOW(m_widget))
|
||||
|
@@ -2040,7 +2040,6 @@ void wxWindowGTK::Init()
|
||||
m_height = 0;
|
||||
|
||||
m_hasVMT = false;
|
||||
m_isBeingDeleted = false;
|
||||
|
||||
m_showOnIdle = false;
|
||||
|
||||
@@ -2210,7 +2209,6 @@ wxWindowGTK::~wxWindowGTK()
|
||||
if ( gs_deferredFocusOut == this )
|
||||
gs_deferredFocusOut = NULL;
|
||||
|
||||
m_isBeingDeleted = true;
|
||||
m_hasVMT = false;
|
||||
|
||||
// destroy children before destroying this window itself
|
||||
|
@@ -229,7 +229,8 @@ bool wxFrame::Create( wxWindow *parent,
|
||||
|
||||
wxFrame::~wxFrame()
|
||||
{
|
||||
m_isBeingDeleted = true;
|
||||
SendDestroyEvent();
|
||||
|
||||
DeleteAllBars();
|
||||
}
|
||||
|
||||
|
@@ -660,7 +660,7 @@ wxTopLevelWindowGTK::~wxTopLevelWindowGTK()
|
||||
RemoveGrab();
|
||||
}
|
||||
|
||||
m_isBeingDeleted = true;
|
||||
SendDestroyEvent();
|
||||
|
||||
// it may also be GtkScrolledWindow in the case of an MDI child
|
||||
if (GTK_IS_WINDOW(m_widget))
|
||||
|
@@ -2437,7 +2437,6 @@ void wxWindowGTK::Init()
|
||||
m_sizeSet = false;
|
||||
m_hasVMT = false;
|
||||
m_needParent = true;
|
||||
m_isBeingDeleted = false;
|
||||
|
||||
m_noExpose = false;
|
||||
m_nativeSizeEvent = false;
|
||||
@@ -2613,7 +2612,6 @@ wxWindowGTK::~wxWindowGTK()
|
||||
if ( g_delayedFocus == this )
|
||||
g_delayedFocus = NULL;
|
||||
|
||||
m_isBeingDeleted = true;
|
||||
m_hasVMT = false;
|
||||
|
||||
// destroy children before destroying this window itself
|
||||
|
@@ -559,8 +559,6 @@ wxWindowMGL::~wxWindowMGL()
|
||||
{
|
||||
SendDestroyEvent();
|
||||
|
||||
m_isBeingDeleted = true;
|
||||
|
||||
if ( gs_mouseCapture == this )
|
||||
ReleaseMouse();
|
||||
|
||||
|
@@ -181,7 +181,7 @@ void wxDialog::SetModal(bool flag)
|
||||
|
||||
wxDialog::~wxDialog()
|
||||
{
|
||||
m_isBeingDeleted = true;
|
||||
SendDestroyEvent();
|
||||
|
||||
// if the dialog is modal, this will end its event loop
|
||||
Show(false);
|
||||
|
@@ -253,7 +253,7 @@ bool wxFrame::XmDoCreateTLW(wxWindow* WXUNUSED(parent),
|
||||
|
||||
wxFrame::~wxFrame()
|
||||
{
|
||||
m_isBeingDeleted = true;
|
||||
SendDestroyEvent();
|
||||
|
||||
if (m_clientArea)
|
||||
{
|
||||
|
@@ -345,11 +345,11 @@ bool wxWindow::Create(wxWindow *parent, wxWindowID id,
|
||||
// Destructor
|
||||
wxWindow::~wxWindow()
|
||||
{
|
||||
SendDestroyEvent();
|
||||
|
||||
if (g_captureWindow == this)
|
||||
g_captureWindow = NULL;
|
||||
|
||||
m_isBeingDeleted = true;
|
||||
|
||||
// Motif-specific actions first
|
||||
WXWidget wMain = GetMainWidget();
|
||||
if ( wMain )
|
||||
|
@@ -59,15 +59,6 @@ IMPLEMENT_ABSTRACT_CLASS(wxControl, wxWindow)
|
||||
// wxControl implementation
|
||||
// ============================================================================
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxControl ctor/dtor
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
wxControl::~wxControl()
|
||||
{
|
||||
m_isBeingDeleted = true;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// control window creation
|
||||
// ----------------------------------------------------------------------------
|
||||
|
@@ -192,8 +192,6 @@ bool wxDialog::Create(wxWindow *parent,
|
||||
|
||||
wxDialog::~wxDialog()
|
||||
{
|
||||
m_isBeingDeleted = true;
|
||||
|
||||
// this will also reenable all the other windows for a modal dialog
|
||||
Show(false);
|
||||
|
||||
|
@@ -209,7 +209,8 @@ bool wxFrame::Create(wxWindow *parent,
|
||||
|
||||
wxFrame::~wxFrame()
|
||||
{
|
||||
m_isBeingDeleted = true;
|
||||
SendDestroyEvent();
|
||||
|
||||
DeleteAllBars();
|
||||
}
|
||||
|
||||
|
@@ -254,7 +254,7 @@ bool wxRadioBox::Create(wxWindow *parent,
|
||||
|
||||
wxRadioBox::~wxRadioBox()
|
||||
{
|
||||
m_isBeingDeleted = true;
|
||||
SendDestroyEvent();
|
||||
|
||||
delete m_radioButtons;
|
||||
if ( m_dummyHwnd )
|
||||
|
@@ -599,6 +599,8 @@ bool wxTopLevelWindowMSW::Create(wxWindow *parent,
|
||||
|
||||
wxTopLevelWindowMSW::~wxTopLevelWindowMSW()
|
||||
{
|
||||
SendDestroyEvent();
|
||||
|
||||
#if defined(__SMARTPHONE__) || defined(__POCKETPC__)
|
||||
SHACTIVATEINFO* info = (SHACTIVATEINFO*) m_activateInfo;
|
||||
delete info;
|
||||
|
@@ -518,7 +518,6 @@ bool wxWindowMSW::MSWCommand(WXUINT WXUNUSED(param), WXWORD WXUNUSED(id))
|
||||
void wxWindowMSW::Init()
|
||||
{
|
||||
// MSW specific
|
||||
m_isBeingDeleted = false;
|
||||
m_oldWndProc = NULL;
|
||||
m_mouseInWindow = false;
|
||||
m_lastKeydownProcessed = false;
|
||||
@@ -540,7 +539,7 @@ void wxWindowMSW::Init()
|
||||
// Destructor
|
||||
wxWindowMSW::~wxWindowMSW()
|
||||
{
|
||||
m_isBeingDeleted = true;
|
||||
SendDestroyEvent();
|
||||
|
||||
#ifndef __WXUNIVERSAL__
|
||||
// VS: make sure there's no wxFrame with last focus set to us:
|
||||
@@ -3949,8 +3948,6 @@ bool wxWindowMSW::HandleCreate(WXLPCREATESTRUCT WXUNUSED_IN_WINCE(cs),
|
||||
|
||||
bool wxWindowMSW::HandleDestroy()
|
||||
{
|
||||
SendDestroyEvent();
|
||||
|
||||
// delete our drop target if we've got one
|
||||
#if wxUSE_DRAG_AND_DROP
|
||||
if ( m_dropTarget != NULL )
|
||||
|
@@ -60,11 +60,6 @@ bool wxControl::Create( wxWindow* pParent,
|
||||
return bRval;
|
||||
} // end of wxControl::Create
|
||||
|
||||
wxControl::~wxControl()
|
||||
{
|
||||
m_isBeingDeleted = true;
|
||||
}
|
||||
|
||||
bool wxControl::OS2CreateControl( const wxChar* zClassname,
|
||||
const wxString& rsLabel,
|
||||
const wxPoint& rPos,
|
||||
|
@@ -147,7 +147,7 @@ void wxDialog::SetModal(bool WXUNUSED(bFlag))
|
||||
|
||||
wxDialog::~wxDialog()
|
||||
{
|
||||
m_isBeingDeleted = true;
|
||||
SendDestroyEvent();
|
||||
|
||||
// this will also reenable all the other windows for a modal dialog
|
||||
Show(false);
|
||||
|
@@ -127,7 +127,8 @@ bool wxFrame::Create( wxWindow* pParent,
|
||||
|
||||
wxFrame::~wxFrame()
|
||||
{
|
||||
m_isBeingDeleted = true;
|
||||
SendDestroyEvent();
|
||||
|
||||
DeleteAllBars();
|
||||
} // end of wxFrame::~wxFrame
|
||||
|
||||
|
@@ -76,7 +76,7 @@ wxRadioBox::wxRadioBox()
|
||||
|
||||
wxRadioBox::~wxRadioBox()
|
||||
{
|
||||
m_isBeingDeleted = true;
|
||||
SendDestroyEvent();
|
||||
|
||||
if (m_hWnd)
|
||||
wxRemoveHandleAssociation(this);
|
||||
|
@@ -334,7 +334,7 @@ void wxWindowOS2::Init()
|
||||
//
|
||||
wxWindowOS2::~wxWindowOS2()
|
||||
{
|
||||
m_isBeingDeleted = true;
|
||||
SendDestroyEvent();
|
||||
|
||||
for (wxWindow* pWin = GetParent(); pWin; pWin = pWin->GetParent())
|
||||
{
|
||||
|
@@ -63,11 +63,6 @@ bool wxControl::Create( wxWindow *parent,
|
||||
return rval;
|
||||
}
|
||||
|
||||
wxControl::~wxControl()
|
||||
{
|
||||
m_isBeingDeleted = true;
|
||||
}
|
||||
|
||||
bool wxControl::ProcessCommand( wxCommandEvent &event )
|
||||
{
|
||||
// Tries:
|
||||
|
@@ -41,8 +41,8 @@ wxDrawerWindow::wxDrawerWindow()
|
||||
|
||||
wxDrawerWindow::~wxDrawerWindow()
|
||||
{
|
||||
m_isBeingDeleted = TRUE;
|
||||
this->Show(FALSE);
|
||||
SendDestroyEvent();
|
||||
Show(FALSE);
|
||||
}
|
||||
|
||||
bool wxDrawerWindow::Create(wxWindow *parent,
|
||||
|
@@ -61,7 +61,8 @@ bool wxFrame::Create(wxWindow *parent,
|
||||
|
||||
wxFrame::~wxFrame()
|
||||
{
|
||||
m_isBeingDeleted = true;
|
||||
SendDestroyEvent();
|
||||
|
||||
DeleteAllBars();
|
||||
}
|
||||
|
||||
|
@@ -71,7 +71,7 @@ void wxDialog::SetModal( bool flag )
|
||||
|
||||
wxDialog::~wxDialog()
|
||||
{
|
||||
m_isBeingDeleted = true;
|
||||
SendDestroyEvent();
|
||||
|
||||
// if the dialog is modal, this will end its event loop
|
||||
Show(false);
|
||||
|
@@ -151,7 +151,7 @@ bool wxNonOwnedWindow::Create(wxWindow *parent,
|
||||
|
||||
wxNonOwnedWindow::~wxNonOwnedWindow()
|
||||
{
|
||||
m_isBeingDeleted = true;
|
||||
SendDestroyEvent();
|
||||
|
||||
wxRemoveWXWindowAssociation( this ) ;
|
||||
|
||||
|
@@ -52,7 +52,7 @@ wxRadioBox::wxRadioBox()
|
||||
|
||||
wxRadioBox::~wxRadioBox()
|
||||
{
|
||||
m_isBeingDeleted = true;
|
||||
SendDestroyEvent();
|
||||
|
||||
wxRadioButton *next, *current;
|
||||
|
||||
|
@@ -141,8 +141,6 @@ wxWindowMac::~wxWindowMac()
|
||||
{
|
||||
SendDestroyEvent();
|
||||
|
||||
m_isBeingDeleted = true;
|
||||
|
||||
MacInvalidateBorders() ;
|
||||
|
||||
#ifndef __WXUNIVERSAL__
|
||||
|
@@ -77,8 +77,9 @@ void wxControl::Init()
|
||||
|
||||
wxControl::~wxControl()
|
||||
{
|
||||
SendDestroyEvent();
|
||||
|
||||
SetLabel(wxEmptyString);
|
||||
m_isBeingDeleted = true;
|
||||
|
||||
DestroyChildren();
|
||||
|
||||
|
@@ -53,8 +53,6 @@ void wxDialog::Init()
|
||||
|
||||
wxDialog::~wxDialog()
|
||||
{
|
||||
m_isBeingDeleted = true;
|
||||
|
||||
// if the dialog is modal, this will end its event loop
|
||||
Show(false);
|
||||
|
||||
|
@@ -224,7 +224,7 @@ bool wxWindow::Create(wxWindow *parent,
|
||||
|
||||
wxWindow::~wxWindow()
|
||||
{
|
||||
m_isBeingDeleted = true;
|
||||
SendDestroyEvent();
|
||||
|
||||
#if wxUSE_SCROLLBAR
|
||||
// clear pointers to scrollbar before deleting the children: they are
|
||||
|
@@ -350,8 +350,6 @@ wxWindowX11::~wxWindowX11()
|
||||
if (g_captureWindow == this)
|
||||
g_captureWindow = NULL;
|
||||
|
||||
m_isBeingDeleted = true;
|
||||
|
||||
DestroyChildren();
|
||||
|
||||
if (m_clientWindow != m_mainWindow)
|
||||
|
Reference in New Issue
Block a user