From 4246c902a5915404116902329d71bb3c0b3c14cd Mon Sep 17 00:00:00 2001 From: donovaly Date: Sun, 25 Oct 2020 01:07:29 +0200 Subject: [PATCH] [PD] fix issue 3968 https://tracker.freecadweb.org/view.php?id=3968 Don't set the tip to features that cannot hold the tip --- src/Mod/PartDesign/Gui/CommandBody.cpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/Mod/PartDesign/Gui/CommandBody.cpp b/src/Mod/PartDesign/Gui/CommandBody.cpp index d6d753bccb..581d34d197 100644 --- a/src/Mod/PartDesign/Gui/CommandBody.cpp +++ b/src/Mod/PartDesign/Gui/CommandBody.cpp @@ -842,13 +842,13 @@ void CmdPartDesignMoveFeatureInTree::activated(int iMsg) bool allFeaturesFromSameBody = true; if ( body ) { - bodyBase= body->BaseFeature.getValue(); + bodyBase = body->BaseFeature.getValue(); for ( auto feat: features ) { if ( !body->hasObject ( feat ) ) { allFeaturesFromSameBody = false; break; } - if ( bodyBase== feat) { + if ( bodyBase == feat) { QMessageBox::warning (0, QObject::tr( "Selection error" ), QObject::tr( "Impossible to move the base feature of a body." ) ); return; @@ -943,17 +943,19 @@ void CmdPartDesignMoveFeatureInTree::activated(int iMsg) // If the selected objects have been moved after the current tip then ask the // user if he wants the last object to be the new tip. - if (lastObject && body->Tip.getValue() == target) { + // Only do this for features that can hold a tip (not for e.g. datums) + if ( lastObject && body->Tip.getValue() == target + && lastObject->isDerivedFrom(PartDesign::Feature::getClassTypeId()) ) { QMessageBox msgBox(Gui::getMainWindow()); msgBox.setIcon(QMessageBox::Question); - msgBox.setWindowTitle(qApp->translate("PartDesign_MoveFeatureInTree","Move tip")); - msgBox.setText(qApp->translate("PartDesign_MoveFeatureInTree","The moved feature appears after the currently set tip.")); - msgBox.setInformativeText(qApp->translate("PartDesign_MoveFeatureInTree","Do you want the last feature to be the new tip?")); + msgBox.setWindowTitle(qApp->translate("PartDesign_MoveFeatureInTree", "Move tip")); + msgBox.setText(qApp->translate("PartDesign_MoveFeatureInTree", "The moved feature appears after the currently set tip.")); + msgBox.setInformativeText(qApp->translate("PartDesign_MoveFeatureInTree", "Do you want the last feature to be the new tip?")); msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No); msgBox.setDefaultButton(QMessageBox::No); int ret = msgBox.exec(); if (ret == QMessageBox::Yes) - FCMD_OBJ_CMD(body,"Tip = " << getObjectCmd(lastObject)); + FCMD_OBJ_CMD(body, "Tip = " << getObjectCmd(lastObject)); } updateActive();