Salome HOME
Issue #1530 The arcs representation is not fine enough
[modules/shaper.git] / src / Config / Config_WidgetAPI.cpp
index 1249f9ab817ecd59e05b037d57a0390ad19caa40..2b74277a142da5059e4024e55dd9a29efb774165 100644 (file)
@@ -46,11 +46,18 @@ bool Config_WidgetAPI::toNextWidget()
 bool Config_WidgetAPI::toChildWidget()
 {
   if (myCurrentNode && hasChild(myCurrentNode)) {
-    myCurrentNode = myCurrentNode->children;
-    while (myCurrentNode && !isElementNode(myCurrentNode)) {
-      myCurrentNode = myCurrentNode->next;
+    xmlNodePtr aChildNode = myCurrentNode->children;
+    // it is possible that among child nodes, there is no an element node, so
+    // we should not change the current node until not-zero node is found
+    // otherwise, it may happens that the current node is null and the node tree information
+    // is lost
+    while (aChildNode && !isElementNode(aChildNode)) {
+      aChildNode = aChildNode->next;
+    }
+    if (aChildNode != NULL) {
+      myCurrentNode = aChildNode;
+      return true;
     }
-    return myCurrentNode != NULL;
   }
   return false;
 }