Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Group.DestroyGroup not working (Read 3300 times)
pelion
Junior Member
**
Offline



Posts: 61
Joined: Nov 12th, 2006
Group.DestroyGroup not working
Dec 5th, 2007 at 2:24am
Print Post  
Hi Stoyo,

In certain circumstances, I am calling

Code
Select All
chart.DestroyGroup(group); 



and getting a 'not in Collection' exception, despite the fact that it is in the chart.Groups collection (as shown by the contains() method, I have even nested the DestroyGroup comand in a 'if contains' clause, which passes, then the DestroyGroup fails)

In my 'immedeate' window in debug I can call the

Code
Select All
chart.DestroyGroup(group); 



succesfully, however in the code it fails.

The actual exception is

Code
Select All
Cannot remove the specified item because it was not found in the specified Collection. 



Stack

Code
Select All
   at System.Collections.CollectionBase.System.Collections.IList.Remove(Object value)
   at MindFusion.Diagramming.WinForms.ArrowCollection.Remove(Arrow arrow)
   at MindFusion.Diagramming.WinForms.FlowChart.xcb9d24c05271f0d0(ChartObject xccb63ca5f63dc470)
   at MindFusion.Diagramming.WinForms.FlowChart.x2237804176f4caea(ChartObject xccb63ca5f63dc470)
   at MindFusion.Diagramming.WinForms.Commands.RemoveItemCmd.Execute(Boolean undoEnabled)
   at MindFusion.Diagramming.WinForms.UndoManager.xdf8cd2685f83d9b7(Command x61b060a94340c4fc)
   at MindFusion.Diagramming.WinForms.Commands.RemoveItemCmd.Execute()
   at MindFusion.Diagramming.WinForms.FlowChart.x7d877b7264517b49(ChartObject xccb63ca5f63dc470)
   at MindFusion.Diagramming.WinForms.Node.x1e79a23123e06c84()
   at MindFusion.Diagramming.WinForms.FlowChart.x2237804176f4caea(ChartObject xccb63ca5f63dc470)
   at MindFusion.Diagramming.WinForms.Commands.RemoveItemCmd.Execute(Boolean undoEnabled)
   at MindFusion.Diagramming.WinForms.UndoManager.xdf8cd2685f83d9b7(Command x61b060a94340c4fc)
   at MindFusion.Diagramming.WinForms.Commands.RemoveItemCmd.Execute()
   at MindFusion.Diagramming.WinForms.FlowChart.x7d877b7264517b49(ChartObject xccb63ca5f63dc470)
   at MindFusion.Diagramming.WinForms.Group.x1728a8b42c4b1ae1(Boolean xcf407f8ccb2b3916)
   at MindFusion.Diagramming.WinForms.Commands.RemoveGroupCmd.Execute(Boolean undoEnabled)
   at MindFusion.Diagramming.WinForms.UndoManager.xdf8cd2685f83d9b7(Command x61b060a94340c4fc)
   at MindFusion.Diagramming.WinForms.Commands.RemoveGroupCmd.Execute()
   at MindFusion.Diagramming.WinForms.FlowChart.DestroyGroup(Group group)
   at Pelion.PM3.SolutionBuilder.Builders.Groups.SolutionGroups.DestroyGroup(GroupType groupType, Hashtable ImageBoxes) in C:\PEPS\R_01_5_5\PM3 



Very strange, very frustrating.

Any ideas?
  
Back to top
 
IP Logged
 
pelion
Junior Member
**
Offline



Posts: 61
Joined: Nov 12th, 2006
Re: Group.DestroyGroup not working
Reply #1 - Dec 5th, 2007 at 2:29am
Print Post  
Hi Stoyo,

I just noticed the

Code
Select All
  at MindFusion.Diagramming.WinForms.ArrowCollection.Remove(Arrow arrow) 



in that stack trace. Even though no arrows should be in the group, there may be arrows whose source nodes are in the group that have been removed, whilst their targets are still on the chart. Would this cause the problem? Anyway in stopping it from destroying arrows on a group destroy (where contained objects are destroyed on the group destruction)?

Thanks
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Group.DestroyGroup not working
Reply #2 - Dec 5th, 2007 at 6:14am
Print Post  
Hi,

Is the AutoDeleteItems property of that group enabled? In such case you could just delete the group's main node - that should automatically destroy the group and delete the child items.

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



Posts: 61
Joined: Nov 12th, 2006
Re: Group.DestroyGroup not working
Reply #3 - Dec 5th, 2007 at 7:22pm
Print Post  
Thanks Stoyo, that's what I was originally doing, but had an arrow remaining from a previous layout, so I tried caching the arrows in to hashtable groups, and remove them seperately.

I'm no longer working down that path and reviewing my code to see why the arrow might not be deleting
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Group.DestroyGroup not working
Reply #4 - Dec 6th, 2007 at 6:22am
Print Post  
Are the cached arrows deleted by some event handler, e.g. NodeDeleted or GroupDestroyed? The control might not detect that and try to delete them for a second time, which would throw that exception. In such case, you could add a check whether an arrow is linked to a box from the group, and if so - do not delete it.

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



Posts: 61
Joined: Nov 12th, 2006
Re: Group.DestroyGroup not working
Reply #5 - Dec 6th, 2007 at 7:27pm
Print Post  
I may have to give that a shot.

Thanks again Stoyo for the follow up
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint