From 00f2a20db376364e0ca3033bc0dd82cfe31580a5 Mon Sep 17 00:00:00 2001 From: nds Date: Tue, 29 Mar 2016 16:56:24 +0300 Subject: [PATCH] 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. --- src/Config/Config_WidgetAPI.cpp | 15 +++++-- src/ModuleBase/ModuleBase_WidgetFactory.cpp | 47 +++++++++++---------- 2 files changed, 36 insertions(+), 26 deletions(-) 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 70eef3959..f9627d525 100644 --- a/src/ModuleBase/ModuleBase_WidgetFactory.cpp +++ b/src/ModuleBase/ModuleBase_WidgetFactory.cpp @@ -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(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()); @@ -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()); -- 2.39.2