Fix autosize columns width calculation in generic wxDataViewCtrl.
Column widths were recomputed too soon -- after the model changed, but before the control's own data structures were updated to reflect the change. This could lead to incorrect calculations or worse, crashes. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@68806 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
5d9138be7f
commit
ac0981084b
@ -1969,7 +1969,6 @@ bool Walker( wxDataViewTreeNode * node, DoJob & func )
|
||||
|
||||
bool wxDataViewMainWindow::ItemAdded(const wxDataViewItem & parent, const wxDataViewItem & item)
|
||||
{
|
||||
GetOwner()->InvalidateColBestWidths();
|
||||
|
||||
if (IsVirtualList())
|
||||
{
|
||||
@ -2004,6 +2003,7 @@ bool wxDataViewMainWindow::ItemAdded(const wxDataViewItem & parent, const wxData
|
||||
m_count = -1;
|
||||
}
|
||||
|
||||
GetOwner()->InvalidateColBestWidths();
|
||||
UpdateDisplay();
|
||||
|
||||
return true;
|
||||
@ -2014,8 +2014,6 @@ static void DestroyTreeHelper( wxDataViewTreeNode * node);
|
||||
bool wxDataViewMainWindow::ItemDeleted(const wxDataViewItem& parent,
|
||||
const wxDataViewItem& item)
|
||||
{
|
||||
GetOwner()->InvalidateColBestWidths();
|
||||
|
||||
if (IsVirtualList())
|
||||
{
|
||||
wxDataViewVirtualListModel *list_model =
|
||||
@ -2128,6 +2126,7 @@ bool wxDataViewMainWindow::ItemDeleted(const wxDataViewItem& parent,
|
||||
if( m_currentRow > GetRowCount() )
|
||||
ChangeCurrentRow(m_count - 1);
|
||||
|
||||
GetOwner()->InvalidateColBestWidths();
|
||||
UpdateDisplay();
|
||||
|
||||
return true;
|
||||
@ -2135,11 +2134,11 @@ bool wxDataViewMainWindow::ItemDeleted(const wxDataViewItem& parent,
|
||||
|
||||
bool wxDataViewMainWindow::ItemChanged(const wxDataViewItem & item)
|
||||
{
|
||||
GetOwner()->InvalidateColBestWidths();
|
||||
|
||||
SortPrepare();
|
||||
g_model->Resort();
|
||||
|
||||
GetOwner()->InvalidateColBestWidths();
|
||||
|
||||
// Send event
|
||||
wxWindow *parent = GetParent();
|
||||
wxDataViewEvent le(wxEVT_COMMAND_DATAVIEW_ITEM_VALUE_CHANGED, parent->GetId());
|
||||
@ -2167,8 +2166,6 @@ bool wxDataViewMainWindow::ValueChanged( const wxDataViewItem & item, unsigned i
|
||||
if (view_column == -1)
|
||||
return false;
|
||||
|
||||
GetOwner()->InvalidateColBestWidth(view_column);
|
||||
|
||||
// NOTE: to be valid, we cannot use e.g. INT_MAX - 1
|
||||
/*#define MAX_VIRTUAL_WIDTH 100000
|
||||
|
||||
@ -2181,6 +2178,8 @@ bool wxDataViewMainWindow::ValueChanged( const wxDataViewItem & item, unsigned i
|
||||
SortPrepare();
|
||||
g_model->Resort();
|
||||
|
||||
GetOwner()->InvalidateColBestWidth(view_column);
|
||||
|
||||
// Send event
|
||||
wxWindow *parent = GetParent();
|
||||
wxDataViewEvent le(wxEVT_COMMAND_DATAVIEW_ITEM_VALUE_CHANGED, parent->GetId());
|
||||
@ -2196,14 +2195,13 @@ bool wxDataViewMainWindow::ValueChanged( const wxDataViewItem & item, unsigned i
|
||||
|
||||
bool wxDataViewMainWindow::Cleared()
|
||||
{
|
||||
GetOwner()->InvalidateColBestWidths();
|
||||
|
||||
DestroyTree();
|
||||
m_selection.Clear();
|
||||
|
||||
SortPrepare();
|
||||
BuildTree( GetOwner()->GetModel() );
|
||||
|
||||
GetOwner()->InvalidateColBestWidths();
|
||||
UpdateDisplay();
|
||||
|
||||
return true;
|
||||
|
Loading…
Reference in New Issue
Block a user