From 80a8cb2f2459425af7e99a86b4593cb6b865cc15 Mon Sep 17 00:00:00 2001 From: vsv Date: Fri, 23 May 2014 13:05:45 +0400 Subject: [PATCH] Document selection on activation of Parts --- src/XGUI/XGUI_Workshop.cpp | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/XGUI/XGUI_Workshop.cpp b/src/XGUI/XGUI_Workshop.cpp index 40a31159a..df5f2e75e 100644 --- a/src/XGUI/XGUI_Workshop.cpp +++ b/src/XGUI/XGUI_Workshop.cpp @@ -740,9 +740,15 @@ void XGUI_Workshop::changeCurrentDocument(FeaturePtr thePart) { PluginManagerPtr aMgr = ModelAPI_PluginManager::get(); if (thePart) { - boost::shared_ptr aDocRef = thePart->data()->docRef("PartDocument"); - if (aDocRef) - aMgr->setCurrentDocument(aDocRef->value()); + DocumentPtr aFeaDoc; + if (thePart->data()) { + aFeaDoc = thePart->data()->docRef("PartDocument")->value(); + } else { + ObjectPtr aObject = boost::dynamic_pointer_cast(thePart); + aFeaDoc = aObject->featureRef()->data()->docRef("PartDocument")->value(); + } + if (aFeaDoc) + aMgr->setCurrentDocument(aFeaDoc); } else { aMgr->setCurrentDocument(aMgr->rootDocument()); } @@ -801,7 +807,13 @@ void XGUI_Workshop::deleteFeatures(QFeatureList theList) aMgr->rootDocument()->startOperation(); foreach (FeaturePtr aFeature, theList) { if (aFeature->getKind() == "Part") { - DocumentPtr aDoc = aFeature->data()->docRef("PartDocument")->value(); + DocumentPtr aDoc; + if (aFeature->data()) { + aDoc = aFeature->data()->docRef("PartDocument")->value(); + } else { + ObjectPtr aObject = boost::dynamic_pointer_cast(aFeature); + aDoc = aObject->featureRef()->data()->docRef("PartDocument")->value(); + } if (aDoc == aMgr->currentDocument()) { aDoc->close(); } -- 2.39.2