Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic ContainerNode.UpdateBounds() and Sub-Groups (Read 2966 times)
mihai
Junior Member
**
Offline



Posts: 86
Joined: Jul 29th, 2009
ContainerNode.UpdateBounds() and Sub-Groups
Aug 27th, 2009 at 7:29am
Print Post  
Hi,

Say I have the following diagram:
- ContainerNode A;
- DiagramNode B contained in A;
- DiagramNode C attached to B, with C.MasterGroup.AutoDeleteItems = true;

If I delete node B and have this in place:
Code
Select All
void diagram_NodeDeleted(object sender, NodeEventArgs e)
{
    A.UpdateBounds();
} 


then UpdateBounds() will throw a NullReferenceException as the sub-group has not yet been fully removed - at least that's my take.

Any idea how to overcome this?

Thanks,
-Mihai
« Last Edit: Aug 27th, 2009 at 11:12am by mihai »  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: ContainerNode.UpdateBounds() and Sub-Groups
Reply #1 - Aug 27th, 2009 at 10:44am
Print Post  
Hi,

Are you calling directly A.UpdateBounds(), or that's a placeholder for some code that looks for the container through e.Node.MasterGroup?

Stoyan
  
Back to top
 
IP Logged
 
mihai
Junior Member
**
Offline



Posts: 86
Joined: Jul 29th, 2009
Re: ContainerNode.UpdateBounds() and Sub-Groups
Reply #2 - Aug 27th, 2009 at 11:12am
Print Post  
Hi Stoyan,

Yes, I'm calling it directly (I store the reference to "A" as a class member).

Thanks,
-Mihai
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: ContainerNode.UpdateBounds() and Sub-Groups
Reply #3 - Sep 5th, 2009 at 2:03pm
Print Post  
Hi Mihai,

Yes, the problem seems to happen because NodeDeleted is raised before the nodes are removed from the container, and the actual exception occurs when it is raised for the C node, while the removal method for B hasn't completed. Try handling it like this:

Code
Select All
private void diagram_NodeDeleted(object sender, NodeEventArgs e)
{
	if (ContainerNode.GetContainer(e.Node) == A)
	{
		A.Remove(e.Node);
		A.UpdateBounds();
	}
}
 



I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
mihai
Junior Member
**
Offline



Posts: 86
Joined: Jul 29th, 2009
Re: ContainerNode.UpdateBounds() and Sub-Groups
Reply #4 - Sep 7th, 2009 at 9:07am
Print Post  
Hi Stoyan,

Thanks, that did the trick!

Talk to you soon,
-Mihai
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint