Fix regression in selection change in wxOSX wxDataViewCtrl

The change of 8aae7ad937 (Fatal exception fixed in DVC on macOS while
wxDataViewModel::Cleared call + editing item., 2022-01-17) broke change
of selection when deleting an item from wxDataViewCtrl and the unit test
checking for this but, somehow, only when it was merged into the latest
master and not when it was originally done.

It's not really clear how did it work before, but fix this now by
distinguishing between just deleting some items and clearing everything
and only returning nil from -[wxCocoaOutlineDataSource
outlineView🧒ofItem:] in the latter case, but not the former one.

Also replace wxDataViewCtrl::m_Deleting boolean with an (opaque)
pointer, so that we could improve this further in the future without
breaking the ABI.

See #22025.
This commit is contained in:
Vadim Zeitlin
2022-02-04 17:12:40 +01:00
parent dbc8506883
commit ff8e60caea
3 changed files with 46 additions and 19 deletions

View File

@@ -230,11 +230,9 @@ public:
return m_CustomRendererPtr;
}
// checks if currently a delete process is running
bool IsDeleting() const
{
return m_Deleting;
}
// checks if a single item or all items are being deleted
bool IsDeleting() const;
bool IsClearing() const;
// with CG, we need to get the context from an kEventControlDraw event
// unfortunately, the DataBrowser callbacks don't provide the context
@@ -296,9 +294,11 @@ private:
//
// variables
//
bool m_Deleting; // flag indicating if a delete process is running; this flag is necessary because the notifier indicating an item deletion in the model may be called
// after the actual deletion of the item; then, native callback functions/delegates may try to update data of variables that are already deleted;
// if this flag is set all native variable update requests will be ignored
// If non-null, describes the item(s) being deleted. This is necessary to
// allow avoiding referencing already deleted items from the native
// callbacks/delegates.
struct wxOSXDVCDeleting* m_Deleting;
// This class can set (and reset) m_Deleting.
friend class wxOSXDVCScopedDeleter;