static int WidthDefault(int w) { return w == wxDefaultCoord ? GetDefaultSize().x : w; }
static int HeightDefault(int h) { return h == wxDefaultCoord ? GetDefaultSize().y : h; }
+ // reset m_winDefault and m_winTmpDefault if they point to the window being
+ // destroyed
+ void OnChildDestroy(wxWindowDestroyEvent& event);
+
+
// the frame icon
wxIconBundle m_icons;
BEGIN_EVENT_TABLE(wxTopLevelWindowBase, wxWindow)
EVT_CLOSE(wxTopLevelWindowBase::OnCloseWindow)
EVT_SIZE(wxTopLevelWindowBase::OnSize)
+ EVT_WINDOW_DESTROY(wxTopLevelWindowBase::OnChildDestroy)
END_EVENT_TABLE()
// ============================================================================
Destroy();
}
+void wxTopLevelWindowBase::OnChildDestroy(wxWindowDestroyEvent& event)
+{
+ event.Skip();
+
+ wxWindow * const win = event.GetWindow();
+ if ( win == m_winDefault )
+ m_winDefault = NULL;
+ if ( win == m_winTmpDefault )
+ m_winTmpDefault = NULL;
+}
+
bool wxTopLevelWindowBase::SendIconizeEvent(bool iconized)
{
wxIconizeEvent event(GetId(), iconized);
wxASSERT_MSG( GetChildren().GetCount() == 0, wxT("children not destroyed") );
- // reset the top-level parent's default item if it is this widget
+ // notify the parent about this window destruction
if ( m_parent )
- {
- wxTopLevelWindow *tlw = wxDynamicCast(wxGetTopLevelParent((wxWindow*)this),
- wxTopLevelWindow);
-
- if ( tlw && tlw->GetDefaultItem() == this )
- tlw->SetDefaultItem(NULL);
- if ( tlw && tlw->GetTmpDefaultItem() == this )
- tlw->SetTmpDefaultItem(NULL);
- }
-
- // reset the dangling pointer our parent window may keep to us
- if ( m_parent )
- {
m_parent->RemoveChild(this);
- }
#if wxUSE_CARET
delete m_caret;