Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Why would CreateGroup return null? (Read 1631 times)
pelion
Junior Member
**
Offline



Posts: 61
Joined: Nov 12th, 2006
Why would CreateGroup return null?
Aug 2nd, 2007 at 8:50pm
Print Post  
The Main Object is not part of any other group

The line
Code
Select All
group = chart.CreateGroup(nodes[0]); 

in the code below returns null, so the LoadGroup function throws a 'null' exception


Code
Select All
  public void CreateGroup(List<Node> nodes, GroupTypes GroupType)
        {
            Group group;
            if (groups.ContainsKey(GroupType))
                groups.Remove(GroupType);
            if (nodes.Count > 0)
            {
                group = chart.CreateGroup(nodes[0]);
                LoadGroup(group, nodes);
                groups.Add(GroupType, group);
            }
        }


  private void LoadGroup(Group group, List<Node> allnodes)
        {
            foreach (Node node in allnodes)
            {
                if (node != group.MainObject)
                    group.AttachToSideMiddle(node, (int)ArrowAnchors.Left);
            }
        }
 



This is happening when I nest groups, whereby a main object of one group will become a subordinate in a parent group.

I do not, however, have an occasion where an object will be used as a main object or a subordinate more than once

Very frustrating, any ideas?
Cheers
JC
« Last Edit: Aug 2nd, 2007 at 11:23pm by pelion »  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Why would CreateGroup return null?
Reply #1 - Aug 3rd, 2007 at 5:35am
Print Post  
CreateGroup returns null in the following situations:

- when it receives null as an argument, i.e. if your nodes[0] is null
- when the argument is already the master item of another group

So, check if nodes[0] is null, or if its SubordinateGroup is already set.

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



Posts: 61
Joined: Nov 12th, 2006
Re: Why would CreateGroup return null?
Reply #2 - Aug 4th, 2007 at 8:55am
Print Post  
A console.write revealed that I was, unintentionally, trying to set a group master with an object already a group master of another group.

Thanks for letting me waste your time Embarrassed

  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint