Fix crash with wxDataViewVirtualListModel in generic wxDataViewCtrl
Recent sorting-related changes resulted in calling FindNode(), which can only be used with the non-"virtual list" models, unconditionally, after the items values was changed by user, resulting in a crash. Add the missing IsVirtualList() check and also add a comment explicitly stating that all code involving wxDataViewTreeNode can only be used after checking that IsVirtualList() returns false. Closes #18057.
This commit is contained in:
@@ -458,6 +458,11 @@ class wxDataViewTreeNode;
|
||||
|
||||
typedef wxVector<wxDataViewTreeNode*> wxDataViewTreeNodes;
|
||||
|
||||
// Note: this class is not used at all for virtual list models, so all code
|
||||
// using it, i.e. any functions taking or returning objects of this type,
|
||||
// including wxDataViewMainWindow::m_root, can only be called after checking
|
||||
// that we're using a non-"virtual list" model.
|
||||
|
||||
class wxDataViewTreeNode
|
||||
{
|
||||
public:
|
||||
@@ -2941,6 +2946,8 @@ bool wxDataViewMainWindow::ItemDeleted(const wxDataViewItem& parent,
|
||||
}
|
||||
|
||||
bool wxDataViewMainWindow::DoItemChanged(const wxDataViewItem & item, int view_column)
|
||||
{
|
||||
if ( !IsVirtualList() )
|
||||
{
|
||||
// Move this node to its new correct place after it was updated.
|
||||
//
|
||||
@@ -2953,6 +2960,7 @@ bool wxDataViewMainWindow::DoItemChanged(const wxDataViewItem & item, int view_c
|
||||
wxDataViewTreeNode* const node = FindNode(item);
|
||||
wxCHECK_MSG( node, false, "invalid item" );
|
||||
node->PutInSortOrder(this);
|
||||
}
|
||||
|
||||
wxDataViewColumn* column;
|
||||
if ( view_column == wxNOT_FOUND )
|
||||
|
Reference in New Issue
Block a user