The new selection concept (see T23751) provides basic classes to introduce the new mechanism. One of the classes is the `QmitkDataStorageSimpleTreeModel` used by `QmitkDataStorageTreeInspector`.
This class is an implementation of the `QmitkAbstractDataStorageModel` and provides an implementation of the `UpdateModelData`-function and the `DataStorageChanged`-function.
However, if `DataStorageChanged` is invoked, which in turn invokes `UpdateModelData`, the workbench crashes in `int QmitkDataStorageTreeModelInternalItem::GetIndex() const`.
`UpdateModelData` is also invoked on initialization when e.g. the data storage is set for the first time. Here no crash happens.
**Edit:**
I couldn't reproduce the problem, because I was not able to reproduce the workflow I used back in 2019. However, I found a way to reproduce the basic problem:
# enable the data storage viewer test plugin
# open MITK and open the data storage viewer test plugin
# load a data node and create a child segmentation node
# show / select the data storage viewer test plugin
# remove the top-level image node inside the datamanager
-> Crash inside `QmitkDataStorageTreeModelInternalItem::IndexOfChild`, called from `QmitkDataStorageTreeModelInternalItem::GetIndex()`
The data storage viewer test plugin is needed to have an additional `QmitkDataStorageSimpleTreeModel` that reacts to the node removed event.
However, my proposed fix does not work here. So maybe this is a completely different bug.
The `QmitkDataStorageSimpleTreeModel` uses the `UpdateModelData`-function to reset its data nodes. This is done by retrieving all nodes from the data storage. Here it seems as if the removed node still exists.
Main message to take away: We should define clear tests for the data storage models and views and test all functionality.