diff --git a/src/Mod/PartDesign/App/Body.cpp b/src/Mod/PartDesign/App/Body.cpp index 6c58a58f4..5d80d34d0 100644 --- a/src/Mod/PartDesign/App/Body.cpp +++ b/src/Mod/PartDesign/App/Body.cpp @@ -257,16 +257,20 @@ void Body::removeFeature(App::DocumentObject* feature) if (tipFeature == feature) { // Set the Tip to the previous feature if possible, otherwise to the next feature std::vector::const_iterator prev = it, next = it; - prev--; - next++; + if (it != model.begin()) { + prev--; + next++; - if (prev != model.end()) { - Tip.setValue(*prev); + if (prev != model.end()) { + Tip.setValue(*prev); + } else { + if (next != model.end()) + Tip.setValue(*next); + else + Tip.setValue(NULL); + } } else { - if (next != model.end()) - Tip.setValue(*next); - else - Tip.setValue(NULL); + Tip.setValue(NULL); } } diff --git a/src/Mod/PartDesign/Gui/TaskGrooveParameters.cpp b/src/Mod/PartDesign/Gui/TaskGrooveParameters.cpp index 30f30b121..50699fb46 100644 --- a/src/Mod/PartDesign/Gui/TaskGrooveParameters.cpp +++ b/src/Mod/PartDesign/Gui/TaskGrooveParameters.cpp @@ -41,7 +41,8 @@ #include #include #include - +#include +#include "Workbench.h" using namespace PartDesignGui; using namespace Gui; @@ -336,6 +337,19 @@ bool TaskDlgGrooveParameters::reject() pcSupport = pcSketch->Support.getValue(); } + // Body housekeeping + if (ActivePartObject != NULL) { + ActivePartObject->removeFeature(pcGroove); + // Make the new Tip and the previous solid feature visible again + App::DocumentObject* tip = ActivePartObject->Tip.getValue(); + App::DocumentObject* prev = ActivePartObject->getPrevSolidFeature(); + if (tip != NULL) { + Gui::Application::Instance->getViewProvider(tip)->show(); + if ((tip != prev) && (prev != NULL)) + Gui::Application::Instance->getViewProvider(prev)->show(); + } + } + // role back the done things Gui::Command::abortCommand(); Gui::Command::doCommand(Gui::Command::Gui,"Gui.activeDocument().resetEdit()"); diff --git a/src/Mod/PartDesign/Gui/TaskPadParameters.cpp b/src/Mod/PartDesign/Gui/TaskPadParameters.cpp index 39641b39a..dd00f657b 100644 --- a/src/Mod/PartDesign/Gui/TaskPadParameters.cpp +++ b/src/Mod/PartDesign/Gui/TaskPadParameters.cpp @@ -45,7 +45,9 @@ #include #include #include +#include #include "ReferenceSelection.h" +#include "Workbench.h" using namespace PartDesignGui; using namespace Gui; @@ -553,6 +555,19 @@ bool TaskDlgPadParameters::reject() pcSketch = static_cast(pcPad->Sketch.getValue()); } + // Body housekeeping + if (ActivePartObject != NULL) { + ActivePartObject->removeFeature(pcPad); + // Make the new Tip and the previous solid feature visible again + App::DocumentObject* tip = ActivePartObject->Tip.getValue(); + App::DocumentObject* prev = ActivePartObject->getPrevSolidFeature(); + if (tip != NULL) { + Gui::Application::Instance->getViewProvider(tip)->show(); + if ((tip != prev) && (prev != NULL)) + Gui::Application::Instance->getViewProvider(prev)->show(); + } + } + // roll back the done things Gui::Command::abortCommand(); Gui::Command::doCommand(Gui::Command::Gui,"Gui.activeDocument().resetEdit()"); diff --git a/src/Mod/PartDesign/Gui/TaskPocketParameters.cpp b/src/Mod/PartDesign/Gui/TaskPocketParameters.cpp index 2a273edd4..8163f8dfb 100644 --- a/src/Mod/PartDesign/Gui/TaskPocketParameters.cpp +++ b/src/Mod/PartDesign/Gui/TaskPocketParameters.cpp @@ -46,7 +46,9 @@ #include #include #include +#include #include "ReferenceSelection.h" +#include "Workbench.h" using namespace PartDesignGui; using namespace Gui; @@ -499,6 +501,19 @@ bool TaskDlgPocketParameters::reject() pcSupport = pcSketch->Support.getValue(); } + // Body housekeeping + if (ActivePartObject != NULL) { + ActivePartObject->removeFeature(pcPocket); + // Make the new Tip and the previous solid feature visible again + App::DocumentObject* tip = ActivePartObject->Tip.getValue(); + App::DocumentObject* prev = ActivePartObject->getPrevSolidFeature(); + if (tip != NULL) { + Gui::Application::Instance->getViewProvider(tip)->show(); + if ((tip != prev) && (prev != NULL)) + Gui::Application::Instance->getViewProvider(prev)->show(); + } + } + // roll back the done things Gui::Command::abortCommand(); Gui::Command::doCommand(Gui::Command::Gui,"Gui.activeDocument().resetEdit()"); diff --git a/src/Mod/PartDesign/Gui/TaskRevolutionParameters.cpp b/src/Mod/PartDesign/Gui/TaskRevolutionParameters.cpp index 911a071f9..3454ab93b 100644 --- a/src/Mod/PartDesign/Gui/TaskRevolutionParameters.cpp +++ b/src/Mod/PartDesign/Gui/TaskRevolutionParameters.cpp @@ -41,6 +41,8 @@ #include #include #include +#include +#include "Workbench.h" using namespace PartDesignGui; @@ -336,6 +338,19 @@ bool TaskDlgRevolutionParameters::reject() pcSupport = pcSketch->Support.getValue(); } + // Body housekeeping + if (ActivePartObject != NULL) { + ActivePartObject->removeFeature(pcRevolution); + // Make the new Tip and the previous solid feature visible again + App::DocumentObject* tip = ActivePartObject->Tip.getValue(); + App::DocumentObject* prev = ActivePartObject->getPrevSolidFeature(); + if (tip != NULL) { + Gui::Application::Instance->getViewProvider(tip)->show(); + if ((tip != prev) && (prev != NULL)) + Gui::Application::Instance->getViewProvider(prev)->show(); + } + } + // role back the done things Gui::Command::abortCommand(); Gui::Command::doCommand(Gui::Command::Gui,"Gui.activeDocument().resetEdit()"); diff --git a/src/Mod/PartDesign/Gui/ViewProvider.cpp b/src/Mod/PartDesign/Gui/ViewProvider.cpp index 076a11c85..7dc15728e 100644 --- a/src/Mod/PartDesign/Gui/ViewProvider.cpp +++ b/src/Mod/PartDesign/Gui/ViewProvider.cpp @@ -82,9 +82,11 @@ bool ViewProvider::onDelete(const std::vector &) // Make the new Tip and the previous solid feature visible again App::DocumentObject* tip = body->Tip.getValue(); App::DocumentObject* prev = body->getPrevSolidFeature(); - Gui::Application::Instance->getViewProvider(tip)->show(); - if (tip != prev) - Gui::Application::Instance->getViewProvider(prev)->show(); + if (tip != NULL) { + Gui::Application::Instance->getViewProvider(tip)->show(); + if ((tip != prev) && (prev != NULL)) + Gui::Application::Instance->getViewProvider(prev)->show(); + } } // TODO: Ask user what to do about dependent objects, e.g. Sketches that have this feature as their support diff --git a/src/Mod/PartDesign/Gui/ViewProviderBody.cpp b/src/Mod/PartDesign/Gui/ViewProviderBody.cpp index b86900811..f7629efb5 100644 --- a/src/Mod/PartDesign/Gui/ViewProviderBody.cpp +++ b/src/Mod/PartDesign/Gui/ViewProviderBody.cpp @@ -157,7 +157,8 @@ void ViewProviderBody::updateTree() for (std::vector::const_iterator f = features.begin(); f != features.end(); f++) { //Base::Console().Error("Highlighting %s: %s\n", (*f)->getNameInDocument(), highlight ? "true" : "false"); Gui::ViewProviderDocumentObject* vp = dynamic_cast(Gui::Application::Instance->getViewProvider(*f)); - ActiveGuiDoc->signalHighlightObject(*vp, Gui::LightBlue, active ? highlight : false); + if (vp != NULL) + ActiveGuiDoc->signalHighlightObject(*vp, Gui::LightBlue, active ? highlight : false); if (highlight && (tip == *f)) highlight = false; }