Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic TreeLayout Crash exception (Read 5381 times)
jmquinlan
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 67
Joined: Apr 2nd, 2009
TreeLayout Crash exception
Apr 30th, 2009 at 11:03am
Print Post  
Hello,

I've got a very simple diagram and got the following exception:

Code
Select All
System.ArgumentOutOfRangeException was unhandled
  Message="Index was out of range. Must be non-negative and less than the size of the collection.\r\nParameter name: index"
  Source="mscorlib"
  ParamName="index"
  StackTrace:
       at System.Collections.CollectionBase.System.Collections.IList.get_Item(Int32 index)
       at MindFusion.Diagramming.AnchorPointCollection.get_Item(Int32 index)
       at MindFusion.Diagramming.x13ba473cd1de406f.GetAnchorPos(Int32 anchorIdx)
       at MindFusion.Diagramming.DiagramLink.xb05f5d996d82647f(Anchoring x7ba664bd6885b404, Boolean x49743b78538984b7)
       at MindFusion.Diagramming.DiagramLink.xb05f5d996d82647f(Anchoring x7ba664bd6885b404)
       at MindFusion.Diagramming.DiagramLink.set_Style(LinkStyle value)
       at MindFusion.Diagramming.Layout.TreeLayout.UpdateLink(DiagramLink a, Boolean ignoredDirection)
       at MindFusion.Diagramming.Layout.TreeLayout.Arrange(Diagram diagram, DiagramItemCollection items)
       at AnimationSequencer.AnimationSequencer.ArrangeSubItems(TreeLayout layout, ContainerNode container) in C:\Perforce\f1\programming\tools\game\AnimationSequencer\AnimationSequencer.cs:line 1815
       at AnimationSequencer.AnimationSequencer.LayoutDiagram() in C:\Perforce\f1\programming\tools\game\AnimationSequencer\AnimationSequencer.cs:line 1851
       at AnimationSequencer.AnimationSequencer.toolStripButton1_Click(Object sender, EventArgs e) in C:\Perforce\f1\programming\tools\game\AnimationSequencer\AnimationSequencer.cs:line 2710
       at System.Windows.Forms.ToolStripItem.RaiseEvent(Object key, EventArgs e)
       at System.Windows.Forms.ToolStripButton.OnClick(EventArgs e)
       at System.Windows.Forms.ToolStripItem.HandleClick(EventArgs e)
       at System.Windows.Forms.ToolStripItem.HandleMouseUp(MouseEventArgs e)
       at System.Windows.Forms.ToolStripItem.FireEventInteractive(EventArgs e, ToolStripItemEventType met)
       at System.Windows.Forms.ToolStripItem.FireEvent(EventArgs e, ToolStripItemEventType met)
       at System.Windows.Forms.ToolStrip.OnMouseUp(MouseEventArgs mea)
       at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
       at System.Windows.Forms.Control.WndProc(Message& m)
       at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
       at System.Windows.Forms.ToolStrip.WndProc(Message& m)
       at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
       at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
       at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
       at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
       at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
       at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
       at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
       at System.Windows.Forms.Application.Run(Form mainForm)
       at AnimationSequencer.Program.Main() in C:\Perforce\f1\programming\tools\game\AnimationSequencer\Program.cs:line 17
       at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
       at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()

 



Ive got 4 table nodes each with 1 input anchor and between (0-2) output anchors.

eg
Code
Select All
containernode
{

        tablenode1----> tablenode2 ------->tablenode3
                                   |
                                   ---->tablenode4
}
 



table node 1 is the rootnode.

I'll send my diagram to you, but the long and short of it is that the link between tablenode1 and tablenode2, is causing this exception.

I put a try catch arround the arrange function that was generating the exception. The resultant diagram after not crashing crashing shows that the link between tablenode1 and tablenode2 had lost its destination anchoring and was now anchored to the container node.




  
Back to top
 
IP Logged
 
jmquinlan
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 67
Joined: Apr 2nd, 2009
Re: TreeLayout Crash exception
Reply #1 - Apr 30th, 2009 at 11:15am
Print Post  
I've just found that if I set my root node to tablenode2 which has 1 incoming link and 2 outgoing links it. it does not throw the exception.

but

If i set tablenode1 which has no incoming links and 1 outgoing link to be the root it causes the exception to be thrown.

how bloody odd...

  
Back to top
 
IP Logged
 
jmquinlan
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 67
Joined: Apr 2nd, 2009
Re: TreeLayout Crash exception
Reply #2 - Apr 30th, 2009 at 11:30am
Print Post  
as a work around I found by doing the following code snippet I can fix the diagram and handle the exception correctly.

Code
Select All
try
{
    layout.Arrange(m_diagram, childItems);
}
catch
{
    foreach (DiagramLink link in m_diagram.Links)
    {
        link.ReassignAnchorPoints();
    }
    m_diagram.RouteAllLinks();
}
 

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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: TreeLayout Crash exception
Reply #3 - Apr 30th, 2009 at 1:14pm
Print Post  
We couldn't reproduce this with the xml you sent us, and that diagram didn't look like the one form your drawing. Could you send us the 4 tables in a container diagram, and also your treelayout initialization code?

Thanks
  
Back to top
 
IP Logged
 
jmquinlan
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 67
Joined: Apr 2nd, 2009
Re: TreeLayout Crash exception
Reply #4 - Apr 30th, 2009 at 4:09pm
Print Post  
Okay I've sent you another email with more details and code in it.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: TreeLayout Crash exception
Reply #5 - May 1st, 2009 at 8:28am
Print Post  
Have you created the diagram from code or by hand? There's a link whose DestinationAnchor is set to 1, while the row's AnchorPattern contains just one point, so the index should be at most 0...
  
Back to top
 
IP Logged
 
jmquinlan
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 67
Joined: Apr 2nd, 2009
Re: TreeLayout Crash exception
Reply #6 - May 1st, 2009 at 3:32pm
Print Post  
I'm programmatically hooking up the links, i suspect its a problem with the following lines of code somewhere.

I have a custom data format which I load the graph from, I load all the nodes and container nodes then I hook the links up after all the nodes are created.

because I need to use multiple rows and anchor points its very important that the correct anchor point is used for a links exit point where as there is only ever one entry point.

Code
Select All
PinnedNode sourceNode = this;
PinnedNode targetNode = pinnedNode;
this.Parent.Factory.CreateDiagramLink(sourceNode, m_links.IndexOf(link) + 1, targetNode);
 



the above code is what is being used to create the links in the diagram that is causing the crash.

I've basically left it up to the diagram to sort out the anchor point as I'm forcing all links to anchor them self to the anchorpoint only. And since there is only one input anchor. I've not specifically told it which anchor to use.

  
Back to top
 
IP Logged
 
jmquinlan
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 67
Joined: Apr 2nd, 2009
Re: TreeLayout Crash exception
Reply #7 - May 1st, 2009 at 3:43pm
Print Post  
Modifying this to be:

Code
Select All
PinnedNode sourceNode = this;
PinnedNode targetNode = pinnedNode;
this.Parent.Factory.CreateDiagramLink(sourceNode, m_links.IndexOf(link) + 1, targetNode, 0);
 



solved the problem and does not adversly effect my links.
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint