Skip to content

Commit

Permalink
fix crash when cancelling revolution task panel
Browse files Browse the repository at this point in the history
  • Loading branch information
wwmayer committed Jan 23, 2017
1 parent 8a100bf commit 294b230
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 8 deletions.
12 changes: 11 additions & 1 deletion src/Mod/PartDesign/Gui/TaskFeatureParameters.cpp
Expand Up @@ -45,7 +45,17 @@ TaskFeatureParameters::TaskFeatureParameters(PartDesignGui::ViewProvider *vp, QW
const std::string& pixmapname, const QString& parname)
: TaskBox(Gui::BitmapFactory().pixmap(pixmapname.c_str()),parname,true, parent),
vp(vp), blockUpdate(false)
{ }
{
Gui::Document* doc = vp->getDocument();
this->attachDocument(doc);
this->enableNotifications(DocumentObserver::Delete);
}

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

void TaskFeatureParameters::onUpdateView(bool on)
{
Expand Down
14 changes: 10 additions & 4 deletions src/Mod/PartDesign/Gui/TaskFeatureParameters.h
Expand Up @@ -26,32 +26,38 @@

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

#include "ViewProvider.h"

namespace PartDesignGui {

/// Convenience class to collect common methods for all SketchBased features
class TaskFeatureParameters : public Gui::TaskView::TaskBox
class TaskFeatureParameters : public Gui::TaskView::TaskBox,
public Gui::DocumentObserver
{
Q_OBJECT

public:
TaskFeatureParameters(PartDesignGui::ViewProvider* vp, QWidget *parent,
const std::string& pixmapname, const QString& parname);
virtual ~TaskFeatureParameters() {};
virtual ~TaskFeatureParameters() {}

/// save field history
virtual void saveHistory(void) {};
virtual void saveHistory(void) {}
/// apply changes made in the parameters input to the model via commands
virtual void apply() {};
virtual void apply() {}

void recomputeFeature();

protected Q_SLOTS:
// TODO Add update view to all dialogs (2015-12-05, Fat-Zer)
void onUpdateView(bool on);

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

protected:
PartDesignGui::ViewProvider *vp;
/// Lock updateUI(), applying changes to the underlying feature and calling recomputeFeature()
Expand Down
6 changes: 3 additions & 3 deletions src/Mod/PartDesign/Gui/TaskRevolutionParameters.cpp
Expand Up @@ -361,8 +361,8 @@ bool TaskRevolutionParameters::getReversed(void) const
TaskRevolutionParameters::~TaskRevolutionParameters()
{
//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();
ViewProviderOrigin* vpOrigin;
Expand All @@ -375,7 +375,7 @@ TaskRevolutionParameters::~TaskRevolutionParameters()

delete ui;

for(size_t i = 0 ; i < axesInList.size() ; i++ ){
for (size_t i = 0; i < axesInList.size(); i++) {
delete axesInList[i];
}
}
Expand Down

0 comments on commit 294b230

Please sign in to comment.