From 51bdecff6f3d2645a9e6605f28dac5c958a669d8 Mon Sep 17 00:00:00 2001 From: Robert Roebling Date: Mon, 19 Nov 2007 13:42:01 +0000 Subject: [PATCH] Free memory of m_root git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@50082 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/generic/datavgen.cpp | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/generic/datavgen.cpp b/src/generic/datavgen.cpp index adcf1b3582..2b3a0180e6 100644 --- a/src/generic/datavgen.cpp +++ b/src/generic/datavgen.cpp @@ -3231,6 +3231,11 @@ void BuildTreeHelper( wxDataViewModel * model, wxDataViewItem & item, wxDataVie void wxDataViewMainWindow::BuildTree(wxDataViewModel * model) { + DestroyTree(); + + m_root = new wxDataViewTreeNode( NULL ); + m_root->SetHasChildren(true); + //First we define a invalid item to fetch the top-level elements wxDataViewItem item; SortPrepare(); @@ -3255,9 +3260,12 @@ void DestroyTreeHelper( wxDataViewTreeNode * node ) void wxDataViewMainWindow::DestroyTree() { - DestroyTreeHelper(m_root); - m_root->SetSubTreeCount(0); - m_count = 0 ; + if (m_root) + { + DestroyTreeHelper(m_root); + m_count = 0; + m_root = NULL; + } } void wxDataViewMainWindow::OnChar( wxKeyEvent &event ) @@ -3784,6 +3792,8 @@ bool wxDataViewCtrl::AssociateModel( wxDataViewModel *model ) model->AddNotifier( m_notifier ); + m_clientArea->DestroyTree(); + m_clientArea->BuildTree(model); m_clientArea->UpdateDisplay();