Salome HOME
Issue #1368: Creation of a Qt panel. documentation correction
[modules/shaper.git] / src / Model / Model_ResultPart.cpp
index 57dcd9a783533374395cb04b82a11d998ae93f8d..a5d266d8165736f94bb7f7581fa4a9a7de4a1b85 100644 (file)
@@ -119,9 +119,13 @@ bool Model_ResultPart::setDisabled(std::shared_ptr<ModelAPI_Result> theThis,
     if (!myTrsf.get()) { // disable of base result part
       DocumentPtr aDoc = Model_ResultPart::partDoc();
       if (aDoc.get() && aDoc->isOpened()) {
-        std::shared_ptr<Model_Document> anIntDoc = std::dynamic_pointer_cast<Model_Document>(aDoc);
         // make the current feature the last in any case: to update shapes defore deactivation too
-        FeaturePtr aLastFeature = anIntDoc->lastFeature();
+        int aSize = aDoc->size(ModelAPI_Feature::group());
+        FeaturePtr aLastFeature;
+        if (aSize)
+          aLastFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(aDoc->object(
+            ModelAPI_Feature::group(), aSize - 1));
+
         aDoc->setCurrentFeature(aLastFeature, false);
         if (theFlag) { // disable, so make all features disabled too
           // update the shape just before the deactivation: it will be used outside of part