From: Václav Slavík Date: Mon, 9 Jan 2012 18:59:23 +0000 (+0000) Subject: Don't crash in generic wxDataViewCtrl if selected column is removed. X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/f52f37959dd8daefc573fc977bbb9aa0810410e5 Don't crash in generic wxDataViewCtrl if selected column is removed. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@70308 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/src/generic/datavgen.cpp b/src/generic/datavgen.cpp index 86bcadf928..536bb64f9c 100644 --- a/src/generic/datavgen.cpp +++ b/src/generic/datavgen.cpp @@ -623,6 +623,9 @@ public: void ChangeCurrentRow( unsigned int row ); bool TryAdvanceCurrentColumn(wxDataViewTreeNode *node, bool forward); + wxDataViewColumn *GetCurrentColumn() const { return m_currentCol; } + void ClearCurrentColumn() { m_currentCol = NULL; } + bool IsSingleSel() const { return !GetParent()->HasFlag(wxDV_MULTIPLE); } bool IsEmpty() { return GetRowCount() == 0; } @@ -4742,6 +4745,10 @@ bool wxDataViewCtrl::DeleteColumn( wxDataViewColumn *column ) m_colsBestWidths.erase(m_colsBestWidths.begin() + GetColumnIndex(column)); m_cols.Erase(ret); + + if ( m_clientArea->GetCurrentColumn() == column ) + m_clientArea->ClearCurrentColumn(); + OnColumnsCountChanged(); return true; @@ -4752,7 +4759,11 @@ bool wxDataViewCtrl::ClearColumns() SetExpanderColumn(NULL); m_cols.Clear(); m_colsBestWidths.clear(); + + m_clientArea->ClearCurrentColumn(); + OnColumnsCountChanged(); + return true; }