Skip to content

Commit

Permalink
+ fix crash when trying to edit broken revolve object
Browse files Browse the repository at this point in the history
  • Loading branch information
wwmayer committed Jul 12, 2014
1 parent 72166ce commit f91c64a
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/Mod/PartDesign/App/FeatureSketchBased.cpp
Expand Up @@ -234,6 +234,8 @@ const TopoDS_Shape& SketchBased::getSupportShape() const {
int SketchBased::getSketchAxisCount(void) const
{
Part::Part2DObject *sketch = static_cast<Part::Part2DObject*>(Sketch.getValue());
if (!sketch)
return -1; // the link to the sketch is lost
return sketch->getAxisCount();
}

Expand Down
9 changes: 7 additions & 2 deletions src/Mod/PartDesign/Gui/ViewProvider.cpp
Expand Up @@ -29,7 +29,7 @@
#include "ViewProvider.h"
#include <Mod/Part/App/PropertyTopoShape.h>
#include <Gui/Command.h>
//#include <Gui/Document.h>
#include <Base/Exception.h>

using namespace PartDesignGui;

Expand All @@ -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;
}

Expand Down
10 changes: 10 additions & 0 deletions src/Mod/PartDesign/Gui/ViewProviderRevolution.cpp
Expand Up @@ -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<PartDesign::Revolution*>(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
Expand Down

0 comments on commit f91c64a

Please sign in to comment.