| 774 | |
| 775 | |
| 776 | void QmitkMultiLabelTreeModel::SetSegmentation(mitk::MultiLabelSegmentation* segmentation) |
| 777 | { |
| 778 | if (m_Segmentation != segmentation) |
| 779 | { |
| 780 | // Keep the old segmentation alive until observer guards are properly reset in AddObserver(). |
| 781 | // Without this, the assignment below may drop the last reference to the old segmentation, |
| 782 | // destroying it before AddObserver() can unregister the old observers. That leads to |
| 783 | // dangling pointers in the ITKEventObserverGuard's WeakPointer and a crash in Lock() |
| 784 | auto previousSegmentation = m_Segmentation; |
| 785 | |
| 786 | this->m_Segmentation = segmentation; |
| 787 | this->AddObserver(); |
| 788 | |
| 789 | this->UpdateInternalTree(); |
| 790 | } |
| 791 | } |
| 792 | |
| 793 | |
| 794 | /**Helper function that adds a labek into the item tree. Passes back the new created instance iten*/ |