When you delete a data node which is currently selected by a QmitkDataStorageComboBox, its selection changes to another still existing data node. And event is fired when the selection changes. However, the newly selected node, which is given as a parameter of the event, is still the old deleted data node. This bug affects all views using the QmitkDataStorageComboBox and leads to undefined behavior or application crashes.
Rough call stack:
QmitkDataStorageComboBox maintains an internal list of items besides the model item list of the QComboBox. In RemoveNode(int index), the index is shortly out of sync since the item was already deleted from the model but not from the internal list m_Nodes. During this phase events are emitted (e.g. OnSelectionChanged) that still point to the already deleted data node instead of the newly selected node.
To fix this, I reordered the lines which erase the item/node:
m_Nodes.erase(m_Nodes.begin() + index); Do this first
this->removeItem(index); An THAN this
[c7c894]: Merge branch 'bug-14919-SelectionChangeOnDataNodeRemoval'
2013-04-10 15:24:03 Stefan Kislinskiy [6bfc93]
Fixed out-of-sync index (Qt model index vs. m_Nodes index).