Skip to content

Commit

Permalink
Fix logic remove
Browse files Browse the repository at this point in the history
The logic tries to find the new active bone node upon deletion. However,
this is impossible because at this point, the bone node's hierarchy node
has already been deleted.
Changing the active node right before deletion fixes this.

Also protecting the OnMRML... methods.

See Issue#13633
  • Loading branch information
vovythevov committed Nov 16, 2012
1 parent 5dc0749 commit 4a483f5
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
15 changes: 14 additions & 1 deletion Modules/Loadable/Armatures/Logic/vtkSlicerArmaturesLogic.cxx
Expand Up @@ -105,6 +105,19 @@ void vtkSlicerArmaturesLogic::RegisterNodes()
this->GetMRMLScene()->RegisterNodeClass( boneDisplayNode.GetPointer() );
}

//----------------------------------------------------------------------------
void vtkSlicerArmaturesLogic::ProcessMRMLSceneEvents(vtkObject* caller,
unsigned long event,
void * callData)
{
this->Superclass::ProcessMRMLSceneEvents(caller, event, callData);
if (event == vtkMRMLScene::NodeAboutToBeRemovedEvent)
{
vtkMRMLNode* node = vtkMRMLNode::SafeDownCast(caller);
this->OnMRMLSceneNodeAboutToBeRemoved(node);
}
}

//-----------------------------------------------------------------------------
void vtkSlicerArmaturesLogic::OnMRMLSceneNodeAdded(vtkMRMLNode* node)
{
Expand All @@ -122,7 +135,7 @@ void vtkSlicerArmaturesLogic::OnMRMLSceneNodeAdded(vtkMRMLNode* node)
}

//-----------------------------------------------------------------------------
void vtkSlicerArmaturesLogic::OnMRMLSceneNodeRemoved(vtkMRMLNode* node)
void vtkSlicerArmaturesLogic::OnMRMLSceneNodeAboutToBeRemoved(vtkMRMLNode* node)
{
this->Superclass::OnMRMLSceneNodeRemoved(node);
vtkMRMLArmatureNode* armatureNode = vtkMRMLArmatureNode::SafeDownCast(node);
Expand Down
9 changes: 6 additions & 3 deletions Modules/Loadable/Armatures/Logic/vtkSlicerArmaturesLogic.h
Expand Up @@ -97,13 +97,16 @@ class VTK_SLICER_ARMATURES_MODULE_LOGIC_EXPORT vtkSlicerArmaturesLogic
/// \sa vtkMRMLScene::RegisterNodeClass()
virtual void RegisterNodes();

virtual void OnMRMLSceneNodeAdded(vtkMRMLNode* node);
virtual void OnMRMLSceneNodeRemoved(vtkMRMLNode* node);

protected:
vtkSlicerArmaturesLogic();
virtual ~vtkSlicerArmaturesLogic();

virtual void ProcessMRMLSceneEvents(vtkObject* caller,
unsigned long event,
void * callData);
virtual void OnMRMLSceneNodeAdded(vtkMRMLNode* node);
virtual void OnMRMLSceneNodeAboutToBeRemoved(vtkMRMLNode* node);

virtual void ProcessMRMLLogicsEvents(vtkObject* caller, unsigned long event,
void* callData);

Expand Down

0 comments on commit 4a483f5

Please sign in to comment.