Skip to content

Commit

Permalink
issue #2836: Crash in sketcher
Browse files Browse the repository at this point in the history
  • Loading branch information
wwmayer committed Jan 23, 2017
1 parent 43e8c21 commit 8a100bf
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
16 changes: 13 additions & 3 deletions src/Mod/PartDesign/Gui/TaskPrimitiveParameters.cpp
Expand Up @@ -220,7 +220,11 @@ TaskBoxPrimitives::TaskBoxPrimitives(ViewProviderPrimitive* vp, QWidget* parent)
if(i != index)
ui.widgetStack->widget(i)->setSizePolicy(QSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored));
}


Gui::Document* doc = vp->getDocument();
this->attachDocument(doc);
this->enableNotifications(DocumentObserver::Delete);

//show the parts coordinate system axis for selection
PartDesign::Body * body = PartDesign::Body::findBodyOf(vp->getObject());
if(body) {
Expand All @@ -241,8 +245,8 @@ TaskBoxPrimitives::TaskBoxPrimitives(ViewProviderPrimitive* vp, QWidget* parent)
TaskBoxPrimitives::~TaskBoxPrimitives()
{
//hide the parts coordinate system axis for selection
PartDesign::Body * body = PartDesign::Body::findBodyOf ( vp->getObject() );
if(body) {
PartDesign::Body * body = vp ? PartDesign::Body::findBodyOf(vp->getObject()) : 0;
if (body) {
try {
App::Origin *origin = body->getOrigin();
Gui::ViewProviderOrigin* vpOrigin;
Expand All @@ -254,6 +258,12 @@ TaskBoxPrimitives::~TaskBoxPrimitives()
}
}

void TaskBoxPrimitives::slotDeletedObject(const Gui::ViewProviderDocumentObject& Obj)
{
if (this->vp == &Obj)
this->vp = nullptr;
}

void TaskBoxPrimitives::onBoxHeightChanged(double v) {
PartDesign::Box* box = static_cast<PartDesign::Box*>(vp->getObject());
box->Height.setValue(v);
Expand Down
10 changes: 8 additions & 2 deletions src/Mod/PartDesign/Gui/TaskPrimitiveParameters.h
Expand Up @@ -26,6 +26,7 @@

#include <Gui/TaskView/TaskView.h>
#include <Gui/Selection.h>
#include <Gui/DocumentObserver.h>
#include <Gui/TaskView/TaskDialog.h>

#include "TaskSketchBasedParameters.h"
Expand All @@ -49,7 +50,8 @@ namespace PartDesignGui {

namespace s = boost::signals;

class TaskBoxPrimitives : public Gui::TaskView::TaskBox
class TaskBoxPrimitives : public Gui::TaskView::TaskBox,
public Gui::DocumentObserver
{
Q_OBJECT

Expand Down Expand Up @@ -98,7 +100,11 @@ public Q_SLOTS:
void onWedgeX2inChanged(double);
void onWedgeZ2maxChanged(double);
void onWedgeZ2inChanged(double);


private:
/** Notifies when the object is about to be removed. */
virtual void slotDeletedObject(const Gui::ViewProviderDocumentObject& Obj);

private:
QWidget* proxy;
Ui_DlgPrimitives ui;
Expand Down

0 comments on commit 8a100bf

Please sign in to comment.