X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/8591268f8f318792178d5a2103a936e73965fdba..56bd6aaca9d758663e202816e1861ee8674526e7:/src/msw/treectrl.cpp diff --git a/src/msw/treectrl.cpp b/src/msw/treectrl.cpp index 58a84c5ac4..c8973fd6b2 100644 --- a/src/msw/treectrl.cpp +++ b/src/msw/treectrl.cpp @@ -88,6 +88,7 @@ // looks quite ugly. #define wxUSE_CHECKBOXES_IN_MULTI_SEL_TREE 0 + // ---------------------------------------------------------------------------- // private functions // ---------------------------------------------------------------------------- @@ -448,7 +449,7 @@ IMPLEMENT_DYNAMIC_CLASS(wxTreeCtrl, wxControl) // ---------------------------------------------------------------------------- // handy table for sending events -static const wxEventType g_events[2][2] = +static wxEventType g_events[2][2] = { { wxEVT_COMMAND_TREE_ITEM_COLLAPSED, wxEVT_COMMAND_TREE_ITEM_COLLAPSING }, { wxEVT_COMMAND_TREE_ITEM_EXPANDED, wxEVT_COMMAND_TREE_ITEM_EXPANDING } @@ -501,8 +502,15 @@ void wxTreeCtrl::Init() m_textCtrl = NULL; m_hasAnyAttr = FALSE; m_dragImage = NULL; - m_htSelStart = 0; + + // Initialize static array of events, because with the new event system, + // they may not be initialized yet. + + g_events[0][0] = wxEVT_COMMAND_TREE_ITEM_COLLAPSED; + g_events[0][1] = wxEVT_COMMAND_TREE_ITEM_COLLAPSING; + g_events[1][0] = wxEVT_COMMAND_TREE_ITEM_EXPANDED; + g_events[1][1] = wxEVT_COMMAND_TREE_ITEM_EXPANDING; } bool wxTreeCtrl::Create(wxWindow *parent, @@ -1596,6 +1604,14 @@ void wxTreeCtrl::DeleteTextCtrl() { if ( m_textCtrl ) { + // the HWND corresponding to this control is deleted by the tree + // control itself and we don't know when exactly this happens, so check + // if the window still exists before calling UnsubclassWin() + if ( !::IsWindow(GetHwndOf(m_textCtrl)) ) + { + m_textCtrl->SetHWND(0); + } + m_textCtrl->UnsubclassWin(); m_textCtrl->SetHWND(0); delete m_textCtrl;