From b99b0eb65b7763bf487ffd1487db5a4c7e9f6110 Mon Sep 17 00:00:00 2001 From: wmayer Date: Thu, 18 May 2017 18:40:56 +0200 Subject: [PATCH] fix crash in pipeline command --- src/Mod/Fem/Gui/Command.cpp | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/src/Mod/Fem/Gui/Command.cpp b/src/Mod/Fem/Gui/Command.cpp index 88bfd4fe57..a7bd46bddd 100644 --- a/src/Mod/Fem/Gui/Command.cpp +++ b/src/Mod/Fem/Gui/Command.cpp @@ -1534,21 +1534,14 @@ void CmdFemPostPipelineFromResult::activated(int) Base::Console().Message("Debug: FemResultObject pointer = %p", result ); */ - App::Document* pcDoc = App::GetApplication().getActiveDocument(); - if(!pcDoc) - { - Base::Console().Message("No active document is found thus do nothing and return\n"); - return; - } - Fem::FemResultObject* result= static_cast(pcDoc->getActiveObject()); - if(result) - { + std::vector results = getSelection().getObjectsOfType(); + if (results.size() == 1) { std::string FeatName = getUniqueObjectName("Pipeline"); openCommand("Create pipeline from result"); doCommand(Doc,"App.activeDocument().addObject('Fem::FemPostPipeline','%s')",FeatName.c_str()); - - //TODO: use python function call for this - static_cast(getDocument()->getObject(FeatName.c_str()))->load(result); + doCommand(Doc,"App.activeDocument().ActiveObject.load(" + "App.activeDocument().getObject(\"%s\"))", results[0]->getNameInDocument()); + commitCommand(); this->updateActive();