Fix crash in wxDataViewTreeCtrl::DeleteAllItems() in wxGTK

Restore the checks for the model stamp, reverting the changes of
18594afe76: we still need to ignore the
calls to at least iter_children() and iter_nth_child() model methods
that can be called from inside gtk_tree_view_set_model() when we reset
the model, as running these methods crashes when trying to use the
pointers to already deleted items.

For consistency and robustness, add checks for the model stamp to all
the methods and not just those two, just in case other ones end up being
called later in some way.

Also add a unit test checking that DeleteAllItems() doesn't crash and
does delete all items.

Closes #18533.
This commit is contained in:
Vadim Zeitlin
2019-10-17 14:57:04 +02:00
parent a3212b35f6
commit 7a980c455e
2 changed files with 99 additions and 2 deletions

View File

@@ -262,4 +262,16 @@ TEST_CASE_METHOD(SingleSelectDataViewCtrlTestCase,
CHECK( rectRoot == wxRect() );
}
TEST_CASE_METHOD(SingleSelectDataViewCtrlTestCase,
"wxDVC::DeleteAllItems",
"[wxDataViewCtrl][delete]")
{
const wxDataViewItem top = m_dvc->GetTopItem();
CHECK( m_dvc->GetChildCount(top) == 1 );
m_dvc->DeleteAllItems();
CHECK( m_dvc->GetChildCount(top) == 0 );
}
#endif //wxUSE_DATAVIEWCTRL