Xcos load: in mixed diagram case only decode the children once 31/17531/1
Clément DAVID [Wed, 2 Dec 2015 16:21:50 +0000 (17:21 +0100)]
Change-Id: Ie83f13b4c818ad63b5c5f00639f5dbc14170cc7f

scilab/modules/xcos/src/java/org/scilab/modules/xcos/io/sax/RawDataHandler.java

index a551638..6d8f0e0 100644 (file)
@@ -40,7 +40,9 @@ import org.xml.sax.Attributes;
 
 import com.mxgraph.model.mxGeometry;
 import com.mxgraph.util.mxPoint;
+import org.scilab.modules.xcos.Kind;
 import org.scilab.modules.xcos.VectorOfInt;
+import org.scilab.modules.xcos.VectorOfScicosID;
 
 class RawDataHandler implements ScilabHandler {
 
@@ -423,9 +425,14 @@ class RawDataHandler implements ScilabHandler {
                         if (fieldValue.as == ObjectProperties.RPAR && fieldValue.value instanceof ScilabMList) {
                             // CORNER CASE for partially decoded sub-diagram hierarchy
                             // decode the rpar as a subdiagram using the legacy decoders
-                            try {
-                                new DiagramElement(saxHandler.controller).decode((ScilabMList) fieldValue.value, new XcosDiagram(cell.getUID(), cell.getKind()));
-                            } catch (ScicosFormatException e) {
+                            // when there is no children
+                            VectorOfScicosID children = new VectorOfScicosID();
+                            saxHandler.controller.getObjectProperty(cell.getUID(), cell.getKind(), ObjectProperties.CHILDREN, children);
+                            if (children.size() == 0) {
+                                try {
+                                    new DiagramElement(saxHandler.controller).decode((ScilabMList) fieldValue.value, new XcosDiagram(cell.getUID(), cell.getKind()));
+                                } catch (ScicosFormatException e) {
+                                }
                             }
                             return;
                         }