diff --git a/src/Mod/PartDesign/App/FeatureSketchBased.cpp b/src/Mod/PartDesign/App/FeatureSketchBased.cpp index d0214815c..32f20c2b5 100644 --- a/src/Mod/PartDesign/App/FeatureSketchBased.cpp +++ b/src/Mod/PartDesign/App/FeatureSketchBased.cpp @@ -234,6 +234,8 @@ const TopoDS_Shape& SketchBased::getSupportShape() const { int SketchBased::getSketchAxisCount(void) const { Part::Part2DObject *sketch = static_cast(Sketch.getValue()); + if (!sketch) + return -1; // the link to the sketch is lost return sketch->getAxisCount(); } diff --git a/src/Mod/PartDesign/Gui/ViewProvider.cpp b/src/Mod/PartDesign/Gui/ViewProvider.cpp index 35981da52..6f16333e9 100644 --- a/src/Mod/PartDesign/Gui/ViewProvider.cpp +++ b/src/Mod/PartDesign/Gui/ViewProvider.cpp @@ -29,7 +29,7 @@ #include "ViewProvider.h" #include #include -//#include +#include using namespace PartDesignGui; @@ -48,7 +48,12 @@ bool ViewProvider::doubleClicked(void) std::string Msg("Edit "); Msg += this->pcObject->Label.getValue(); Gui::Command::openCommand(Msg.c_str()); - Gui::Command::doCommand(Gui::Command::Gui,"Gui.activeDocument().setEdit('%s',0)",this->pcObject->getNameInDocument()); + try { + Gui::Command::doCommand(Gui::Command::Gui,"Gui.activeDocument().setEdit('%s',0)",this->pcObject->getNameInDocument()); + } + catch (const Base::Exception&) { + Gui::Command::abortCommand(); + } return true; } diff --git a/src/Mod/PartDesign/Gui/ViewProviderRevolution.cpp b/src/Mod/PartDesign/Gui/ViewProviderRevolution.cpp index 5715b0231..89ea2acba 100644 --- a/src/Mod/PartDesign/Gui/ViewProviderRevolution.cpp +++ b/src/Mod/PartDesign/Gui/ViewProviderRevolution.cpp @@ -67,6 +67,16 @@ void ViewProviderRevolution::setupContextMenu(QMenu* menu, QObject* receiver, co bool ViewProviderRevolution::setEdit(int ModNum) { if (ModNum == ViewProvider::Default ) { + PartDesign::Revolution* pcRevolution = static_cast(getObject()); + if (pcRevolution->getSketchAxisCount() < 0) { + QMessageBox msgBox; + msgBox.setIcon(QMessageBox::Critical); + msgBox.setWindowTitle(QObject::tr("Lost link to base sketch")); + msgBox.setText(QObject::tr("The object can't be edited because the link to the the base sketch is lost.")); + msgBox.setStandardButtons(QMessageBox::Ok); + msgBox.exec(); + return false; + } // When double-clicking on the item for this pad the // object unsets and sets its edit mode without closing // the task panel