Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Error saving CompositeNode to XML (Read 6115 times)
AR
Junior Member
**
Offline


I Love MindFusion!

Posts: 65
Joined: Jan 23rd, 2015
Error saving CompositeNode to XML
Nov 29th, 2016 at 10:41am
Print Post  
We have been using Composite Nodes for several years without problems, but we have suddenly noticed an error which occurs when we create and save several nodes in a row (usually but not always the 4th Node causes the error).

The error text is:
Code
Select All
29-Nov-2016 05:07:23,805 ERROR - [ourClass]                           - Error saving diagram data
java.lang.NullPointerException
        at com.mindfusion.diagramming.XmlPersistContext.writeRectangleF(Unknown Source)
        at com.mindfusion.diagramming.components.ComponentBase.saveToXml(Unknown Source)
        at com.mindfusion.diagramming.components.ContainerComponent.saveToXml(Unknown Source)
        at com.mindfusion.diagramming.components.ContainerComponent.saveComponents(Unknown Source)
        at com.mindfusion.diagramming.CompositeNode.saveToXml(Unknown Source)
...... 


We would like to understand why this might be happening so we can try to prevent or handle it.

Can you shed any light on possible causes of this problem?

(OS: Windows 10, Java Version: 1.8.0_74-b02 JVM Version: 64)
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3152
Joined: Oct 19th, 2005
Re: Error saving CompositeNode to XML
Reply #1 - Nov 30th, 2016 at 9:01am
Print Post  
Is there any difference between that 4th node and the previous ones? like containing different kinds of components?
  
Back to top
 
IP Logged
 
AR
Junior Member
**
Offline


I Love MindFusion!

Posts: 65
Joined: Jan 23rd, 2015
Re: Error saving CompositeNode to XML
Reply #2 - Nov 30th, 2016 at 10:11am
Print Post  
No they are all the same - contain some text and an image and an empty node which will contain text later.

We wondered if specific text or a specific image was the problem but have tested lots of different text and images in lots of orders without any pattern other than it is usually about the 4th one.

But it can be the first Composite Node on a particular diagram sometimes, especially if we've put several of the Composite Nodes on another diagram first.
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3152
Joined: Oct 19th, 2005
Re: Error saving CompositeNode to XML
Reply #3 - Nov 30th, 2016 at 10:42am
Print Post  
What do you mean by an empty node? A TextComponent without text set, or an empty panel component?
  
Back to top
 
IP Logged
 
AR
Junior Member
**
Offline


I Love MindFusion!

Posts: 65
Joined: Jan 23rd, 2015
Re: Error saving CompositeNode to XML
Reply #4 - Nov 30th, 2016 at 11:43am
Print Post  
A text component without any text set.
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3152
Joined: Oct 19th, 2005
Re: Error saving CompositeNode to XML
Reply #5 - Nov 30th, 2016 at 12:47pm
Print Post  
Are you using the SimplePanel component? I can see uninitialized Rectangle2D field in its code which would crash if the layout pass hasn't passed at least once, e.g. if you call saveToXml immediately after adding a node. Check if running this before savetoXml will fix it -

Code
Select All
Graphics2D g = (Graphics2D)getGraphics();
for (DiagramNode node : diagram.getNodes())
{
	if (node instanceof CompositeNode)
	{
		Rectangle2D.Float r = node.getBounds();
		((CompositeNode)node).arrangeComponents(
			new Rectangle2D.Float(0, 0, r.width, r.height), g);
	}
} 

« Last Edit: Dec 1st, 2016 at 10:08am by Slavcho »  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3152
Joined: Oct 19th, 2005
Re: Error saving CompositeNode to XML
Reply #6 - Dec 1st, 2016 at 10:08am
Print Post  
This build should let you save without showing components on screen first -
https://mindfusion.eu/_temp/jdiag_compxml.zip

Code
Select All
CompositeNode node = new CompositeNode();
node.getComponents().add(new SimplePanel());
node.getComponents().add(new TextComponent());
node.getComponents().add(new ImageComponent());
diagram.getNodes().add(node);
diagram.saveToXml("test.xml"); 



Regards,
Slavcho
Mindfusion
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint