fix pd tools from running when no active parts

This commit is contained in:
Sergo 2017-02-20 00:58:36 -05:00 committed by Yorik van Havre
parent 8300306f82
commit f8e836221c

View File

@ -1612,6 +1612,14 @@ CmdPartDesignMirrored::CmdPartDesignMirrored()
void CmdPartDesignMirrored::activated(int iMsg) void CmdPartDesignMirrored::activated(int iMsg)
{ {
Q_UNUSED(iMsg); Q_UNUSED(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; Gui::Command* cmd = this;
auto worker = [this, cmd](std::string FeatName, std::vector<App::DocumentObject*> features) { auto worker = [this, cmd](std::string FeatName, std::vector<App::DocumentObject*> features) {
@ -1666,6 +1674,14 @@ CmdPartDesignLinearPattern::CmdPartDesignLinearPattern()
void CmdPartDesignLinearPattern::activated(int iMsg) void CmdPartDesignLinearPattern::activated(int iMsg)
{ {
Q_UNUSED(iMsg); Q_UNUSED(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; Gui::Command* cmd = this;
auto worker = [this, cmd](std::string FeatName, std::vector<App::DocumentObject*> features) { auto worker = [this, cmd](std::string FeatName, std::vector<App::DocumentObject*> features) {
@ -1722,6 +1738,14 @@ CmdPartDesignPolarPattern::CmdPartDesignPolarPattern()
void CmdPartDesignPolarPattern::activated(int iMsg) void CmdPartDesignPolarPattern::activated(int iMsg)
{ {
Q_UNUSED(iMsg); Q_UNUSED(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; Gui::Command* cmd = this;
auto worker = [this, cmd](std::string FeatName, std::vector<App::DocumentObject*> features) { auto worker = [this, cmd](std::string FeatName, std::vector<App::DocumentObject*> features) {
@ -1819,8 +1843,13 @@ CmdPartDesignMultiTransform::CmdPartDesignMultiTransform()
void CmdPartDesignMultiTransform::activated(int iMsg) void CmdPartDesignMultiTransform::activated(int iMsg)
{ {
Q_UNUSED(iMsg); Q_UNUSED(iMsg);
PartDesign::Body *pcActiveBody = PartDesignGui::getBody(/*messageIfNot = */false); App::Document *doc = getDocument();
//if (!pcActiveBody) return; PartDesign::Body *pcActiveBody = PartDesignGui::getBody(
/*messageIfNot = */ PartDesignGui::assureModernWorkflow(doc));
// No PartDesign feature without Body past FreeCAD 0.16
if (!pcActiveBody && PartDesignGui::isModernWorkflow(doc))
return;
std::vector<App::DocumentObject*> features; std::vector<App::DocumentObject*> features;