Salome HOME
Issue #1343 Improvement of Extrusion and Revolution operations: correction for the...
authornds <nds@opencascade.com>
Tue, 29 Mar 2016 13:56:24 +0000 (16:56 +0300)
committerdbv <dbv@opencascade.com>
Wed, 6 Apr 2016 10:25:15 +0000 (13:25 +0300)
src/Config/Config_WidgetAPI.cpp
src/ModuleBase/ModuleBase_WidgetFactory.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;
 }
index 70eef3959a96f42f70f7ca2dedefcd854cc0f19a..f9627d5259ac72bead2166c8b06f986a624f76f5 100644 (file)
@@ -111,20 +111,21 @@ void ModuleBase_WidgetFactory::createWidget(ModuleBase_PageBase* thePage)
       if (myWidgetApi->isPagedWidget()) {
         //If current widget is toolbox or switch-casebox then fetch all
         //it's pages recursively and setup into the widget.
-        myWidgetApi->toChildWidget();
-        do {
-          QString aPageName = qs(myWidgetApi->getProperty(CONTAINER_PAGE_NAME));
-          QString aCaseId = qs(myWidgetApi->getProperty(_ID));
-          ModuleBase_PageBase* aPage = new ModuleBase_PageWidget(aWidget);
-          createWidget(aPage);
-          if (aWdgType == WDG_SWITCH || aWdgType == WDG_TOOLBOX) {
-            ModuleBase_PagedContainer* aContainer = qobject_cast<ModuleBase_PagedContainer*>(aWidget);
-
-            QString anIconPath = qs( myWidgetApi->getProperty( CONTAINER_PAGE_ICON ) );
-            QPixmap anIcon( anIconPath );
-            aContainer->addPage( aPage, aPageName, aCaseId, anIcon );
-          }
-        } while (myWidgetApi->toNextWidget());
+        if (myWidgetApi->toChildWidget()) {
+          do {
+            QString aPageName = qs(myWidgetApi->getProperty(CONTAINER_PAGE_NAME));
+            QString aCaseId = qs(myWidgetApi->getProperty(_ID));
+            ModuleBase_PageBase* aPage = new ModuleBase_PageWidget(aWidget);
+            createWidget(aPage);
+            if (aWdgType == WDG_SWITCH || aWdgType == WDG_TOOLBOX) {
+              ModuleBase_PagedContainer* aContainer = qobject_cast<ModuleBase_PagedContainer*>(aWidget);
+
+              QString anIconPath = qs( myWidgetApi->getProperty( CONTAINER_PAGE_ICON ) );
+              QPixmap anIcon( anIconPath );
+              aContainer->addPage( aPage, aPageName, aCaseId, anIcon );
+            }
+          } while (myWidgetApi->toNextWidget());
+        }
       }
     }
   } while (myWidgetApi->toNextWidget());
@@ -201,10 +202,11 @@ void ModuleBase_WidgetFactory::getGreedAttribute(std::string& theAttributeId)
       if (theAttributeId.empty() && myWidgetApi->isPagedWidget()) {
         //If current widget is toolbox or switch-casebox then fetch all
         //it's pages recursively and setup into the widget.
-        myWidgetApi->toChildWidget();
-        do {
-          getGreedAttribute(theAttributeId);
-        } while (theAttributeId.empty() && myWidgetApi->toNextWidget());
+        if (myWidgetApi->toChildWidget()) {
+          do {
+            getGreedAttribute(theAttributeId);
+          } while (theAttributeId.empty() && myWidgetApi->toNextWidget());
+        }
       }
     }
   } while (theAttributeId.empty() && myWidgetApi->toNextWidget());
@@ -232,10 +234,11 @@ void ModuleBase_WidgetFactory::moveToWidgetId(const std::string& theWidgetId, bo
       if (!theFound && myWidgetApi->isPagedWidget()) {
         //If current widget is toolbox or switch-casebox then fetch all
         //it's pages recursively and setup into the widget.
-        myWidgetApi->toChildWidget();
-        do {
-          moveToWidgetId(theWidgetId, theFound);
-        } while (!theFound && myWidgetApi->toNextWidget());
+        if (myWidgetApi->toChildWidget()) {
+          do {
+            moveToWidgetId(theWidgetId, theFound);
+          } while (!theFound && myWidgetApi->toNextWidget());
+        }
       }
     }
   } while (!theFound && myWidgetApi->toNextWidget());