From 9f0db2d90091c6fe721a4219ee58089fb8e1fd2b Mon Sep 17 00:00:00 2001 From: Sergo Date: Tue, 12 Jul 2016 23:18:01 -0400 Subject: [PATCH] refuse to create partdesign objects if no active body in document --- src/Mod/PartDesign/Gui/Command.cpp | 55 ++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/src/Mod/PartDesign/Gui/Command.cpp b/src/Mod/PartDesign/Gui/Command.cpp index d3ceff674..80b43bb85 100644 --- a/src/Mod/PartDesign/Gui/Command.cpp +++ b/src/Mod/PartDesign/Gui/Command.cpp @@ -870,6 +870,14 @@ CmdPartDesignPad::CmdPartDesignPad() void CmdPartDesignPad::activated(int iMsg) { + App::Document *doc = getDocument(); + PartDesign::Body *pcActiveBody = PartDesignGui::getBody( + /*messageIfNot = */ PartDesignGui::assureModernWorkflow(doc)); + + // No PartDesign feature without Body past FreeCAD 0.16 + if (!pcActiveBody && PartDesignGui::isModernWorkflow(doc)) + return; + Gui::Command* cmd = this; auto worker = [cmd](Part::Feature* profile, std::string FeatName) { @@ -919,6 +927,14 @@ CmdPartDesignPocket::CmdPartDesignPocket() void CmdPartDesignPocket::activated(int iMsg) { + App::Document *doc = getDocument(); + PartDesign::Body *pcActiveBody = PartDesignGui::getBody( + /*messageIfNot = */ PartDesignGui::assureModernWorkflow(doc)); + + // No PartDesign feature without Body past FreeCAD 0.16 + if (!pcActiveBody && PartDesignGui::isModernWorkflow(doc)) + return; + Gui::Command* cmd = this; auto worker = [cmd](Part::Feature* sketch, std::string FeatName) { @@ -956,6 +972,14 @@ CmdPartDesignRevolution::CmdPartDesignRevolution() void CmdPartDesignRevolution::activated(int iMsg) { + App::Document *doc = getDocument(); + PartDesign::Body *pcActiveBody = PartDesignGui::getBody( + /*messageIfNot = */ PartDesignGui::assureModernWorkflow(doc)); + + // No PartDesign feature without Body past FreeCAD 0.16 + if (!pcActiveBody && PartDesignGui::isModernWorkflow(doc)) + return; + Gui::Command* cmd = this; auto worker = [cmd](Part::Feature* sketch, std::string FeatName) { @@ -999,6 +1023,13 @@ CmdPartDesignGroove::CmdPartDesignGroove() void CmdPartDesignGroove::activated(int iMsg) { + App::Document *doc = getDocument(); + PartDesign::Body *pcActiveBody = PartDesignGui::getBody( + /*messageIfNot = */ PartDesignGui::assureModernWorkflow(doc)); + + if (!pcActiveBody && PartDesignGui::isModernWorkflow(doc)) + return; + Gui::Command* cmd = this; auto worker = [cmd](Part::Feature* sketch, std::string FeatName) { @@ -1042,6 +1073,12 @@ CmdPartDesignAdditivePipe::CmdPartDesignAdditivePipe() void CmdPartDesignAdditivePipe::activated(int iMsg) { + PartDesign::Body *pcActiveBody = PartDesignGui::getBody(/*messageIfNot = */ true); + + // No PartDesign feature without Body past FreeCAD 0.13 + if (!pcActiveBody) + return; + Gui::Command* cmd = this; auto worker = [cmd](Part::Feature* sketch, std::string FeatName) { @@ -1082,6 +1119,12 @@ CmdPartDesignSubtractivePipe::CmdPartDesignSubtractivePipe() void CmdPartDesignSubtractivePipe::activated(int iMsg) { + PartDesign::Body *pcActiveBody = PartDesignGui::getBody(/*messageIfNot = */ true); + + // No PartDesign feature without Body past FreeCAD 0.13 + if (!pcActiveBody) + return; + Gui::Command* cmd = this; auto worker = [cmd](Part::Feature* sketch, std::string FeatName) { @@ -1122,6 +1165,12 @@ CmdPartDesignAdditiveLoft::CmdPartDesignAdditiveLoft() void CmdPartDesignAdditiveLoft::activated(int iMsg) { + PartDesign::Body *pcActiveBody = PartDesignGui::getBody(/*messageIfNot = */ true); + + // No PartDesign feature without Body past FreeCAD 0.13 + if (!pcActiveBody) + return; + Gui::Command* cmd = this; auto worker = [cmd](Part::Feature* sketch, std::string FeatName) { @@ -1162,6 +1211,12 @@ CmdPartDesignSubtractiveLoft::CmdPartDesignSubtractiveLoft() void CmdPartDesignSubtractiveLoft::activated(int iMsg) { + PartDesign::Body *pcActiveBody = PartDesignGui::getBody(/*messageIfNot = */ true); + + // No PartDesign feature without Body past FreeCAD 0.13 + if (!pcActiveBody) + return; + Gui::Command* cmd = this; auto worker = [cmd](Part::Feature* sketch, std::string FeatName) {