In QmitkMultiLabelSegmentationView::CreateQtPartControl(QWidget *parent) and QmitSegmentationView::CreateQtPartControl(QWidget *parent) one can find a proplematic code:
// set callback function for already existing segmentation nodes mitk::DataStorage::SetOfObjects::ConstPointer allSegmentations = GetDataStorage()->GetSubset(m_SegmentationPredicate); for (mitk::DataStorage::SetOfObjects::const_iterator iter = allSegmentations->begin(); iter != allSegmentations->end(); ++iter) { mitk::DataNode* node = *iter; auto command = itk::SimpleMemberCommand<QmitkMultiLabelSegmentationView>::New(); command->SetCallbackFunction(this, &QmitkMultiLabelSegmentationView::ValidateSelectionInput); m_WorkingDataObserverTags.insert(std::pair<mitk::DataNode *, unsigned long>( node, node->GetProperty("visible")->AddObserver(itk::ModifiedEvent(), command))); }
Problem: code assumes that property "visible" does always exist. If this is not the case, code crashes (that was the problem reported by T28886) when trying to call AddObserver. In some situations (e.g. custom written scene files) this could happen.
The problem could be prevented with a check for existance, but I want to discuss if this kind of observer pattern still make sense here. If I see the code in ValidateSelectionInput() correctly, which is called by the observer, it does the following:
- checks if the geometry of reference and working image fits
- checks if they are visible
- acts accordingly
To attach an observer on each segmentation node seems over bloated. I think just monitor the visiblity states of the current working image and reference image, would be sufficient.
ToDo: Discuss and conclude how to handle.