Page MenuHomePhabricator

Workbench crash on simple tree model update
Open, NormalPublic

Description

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.

Event Timeline

kalali triaged this task as Normal priority.Jun 12 2019, 4:06 PM
kalali created this task.

Possible solutions:

  1. Add
if (!parentItem)
    return QModelIndex();

to QModelIndex QmitkDataStorageSimpleTreeModel::parent(const QModelIndex &child) const

  1. Remove
if (m_Root)
{
  m_Root->Delete();
}

from void QmitkDataStorageSimpleTreeModel::DataStorageChanged(). This will lead to unreferenced pointers so I suggest to work with smart pointers (for this QmitkDataStorageTreeModelInternalItem needs to be modified).

One reason could be that a child item that is removed by calling Delete on the root item is not removed from m_TreeItems and thus will still be returned when using TreeItemFromIndex inside QmitkDataStorageSimpleTreeModel::parent. Just a quick guess.