From: nds Date: Tue, 29 Mar 2016 13:56:24 +0000 (+0300) Subject: Issue #1343 Improvement of Extrusion and Revolution operations: correction for the... X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=b4b753edfa63ca0124e98d512d8ed89b79176702;p=modules%2Fshaper.git Issue #1343 Improvement of Extrusion and Revolution operations: correction for the bug: there was a crash on using: , if is used, the result is correct. The reason is that there are not elements in the construction. This will be used in the Pipe feature. --- diff --git a/src/Config/Config_WidgetAPI.cpp b/src/Config/Config_WidgetAPI.cpp index 1249f9ab8..2b74277a1 100644 --- a/src/Config/Config_WidgetAPI.cpp +++ b/src/Config/Config_WidgetAPI.cpp @@ -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; } diff --git a/src/ModuleBase/ModuleBase_WidgetFactory.cpp b/src/ModuleBase/ModuleBase_WidgetFactory.cpp index 41709a1ba..629a18df1 100644 --- a/src/ModuleBase/ModuleBase_WidgetFactory.cpp +++ b/src/ModuleBase/ModuleBase_WidgetFactory.cpp @@ -99,20 +99,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(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(aWidget); + + QString anIconPath = qs( myWidgetApi->getProperty( CONTAINER_PAGE_ICON ) ); + QPixmap anIcon( anIconPath ); + aContainer->addPage( aPage, aPageName, aCaseId, anIcon ); + } + } while (myWidgetApi->toNextWidget()); + } } } } while (myWidgetApi->toNextWidget()); @@ -177,10 +178,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()); @@ -208,10 +210,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());