From bebda4c6adcad59c4abe82bcbc8703e90c8e1ceb Mon Sep 17 00:00:00 2001 From: wmayer Date: Tue, 24 Jan 2017 15:00:41 +0100 Subject: [PATCH] fix crash when pressing cancel on pipe task panel --- src/Mod/PartDesign/Gui/TaskPipeParameters.cpp | 71 ++++++++++--------- 1 file changed, 38 insertions(+), 33 deletions(-) diff --git a/src/Mod/PartDesign/Gui/TaskPipeParameters.cpp b/src/Mod/PartDesign/Gui/TaskPipeParameters.cpp index 663fd0f47..275d4203b 100644 --- a/src/Mod/PartDesign/Gui/TaskPipeParameters.cpp +++ b/src/Mod/PartDesign/Gui/TaskPipeParameters.cpp @@ -67,7 +67,7 @@ using namespace Gui; // Task Parameter //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -TaskPipeParameters::TaskPipeParameters(ViewProviderPipe *PipeView,bool /*newObj*/, QWidget *parent) +TaskPipeParameters::TaskPipeParameters(ViewProviderPipe *PipeView, bool /*newObj*/, QWidget *parent) : TaskSketchBasedParameters(PipeView, parent, "PartDesign_Additive_Pipe",tr("Pipe parameters")) { // we need a separate container widget to add all controls to @@ -84,15 +84,15 @@ TaskPipeParameters::TaskPipeParameters(ViewProviderPipe *PipeView,bool /*newObj* this, SLOT(onButtonRefRemove(bool))); connect(ui->buttonProfileBase, SIGNAL(toggled(bool)), this, SLOT(onBaseButton(bool))); - + this->groupLayout()->addWidget(proxy); - + PartDesign::Pipe* pipe = static_cast(PipeView->getObject()); - Gui::Document* doc = Gui::Application::Instance->activeDocument(); - - //make sure th euser sees al important things: the - //spine/auxillery spine he already selected - if(pipe->Spine.getValue()) { + Gui::Document* doc = PipeView->getDocument(); + + //make sure the user sees all important things: the + //spine/auxilliary spine he already selected + if (pipe->Spine.getValue()) { auto* svp = doc->getViewProvider(pipe->Spine.getValue()); spineShow = svp->isShow(); svp->setVisible(true); @@ -104,9 +104,9 @@ TaskPipeParameters::TaskPipeParameters(ViewProviderPipe *PipeView,bool /*newObj* std::vector strings = pipe->Spine.getSubValues(); for (std::vector::const_iterator i = strings.begin(); i != strings.end(); i++) ui->listWidgetReferences->addItem(QString::fromStdString(*i)); - + ui->comboBoxTransition->setCurrentIndex(pipe->Transition.getValue()); - + updateUI(); } @@ -151,18 +151,21 @@ void TaskPipeParameters::onSelectionChanged(const Gui::SelectionChanges& msg) TaskPipeParameters::~TaskPipeParameters() { - PartDesign::Pipe* pipe = static_cast(vp->getObject()); - Gui::Document* doc = Gui::Application::Instance->activeDocument(); - - //make sure th euser sees al important things: the - //spine/auxillery spine he already selected - if(pipe->Spine.getValue()) { - auto* svp = doc->getViewProvider(pipe->Spine.getValue()); - svp->setVisible(spineShow); - spineShow = false; + if (vp) { + PartDesign::Pipe* pipe = static_cast(vp->getObject()); + Gui::Document* doc = vp->getDocument(); + + //make sure the user sees all important things: the + //spine/auxilliary spine he already selected + if (pipe->Spine.getValue()) { + auto* svp = doc->getViewProvider(pipe->Spine.getValue()); + svp->setVisible(spineShow); + spineShow = false; + } + + static_cast(vp)->highlightReferences(false, false); } - static_cast(vp)->highlightReferences(false, false); - + delete ui; } @@ -340,20 +343,22 @@ TaskPipeOrientation::TaskPipeOrientation(ViewProviderPipe* PipeView, bool /*newO updateUI(pipe->Mode.getValue()); } -TaskPipeOrientation::~TaskPipeOrientation() { +TaskPipeOrientation::~TaskPipeOrientation() +{ + if (vp) { + PartDesign::Pipe* pipe = static_cast(vp->getObject()); + Gui::Document* doc = vp->getDocument(); - PartDesign::Pipe* pipe = static_cast(vp->getObject()); - Gui::Document* doc = Gui::Application::Instance->activeDocument(); - - //make sure th euser sees al important things: the base feature to select edges and the - //spine/auxillery spine he already selected - if(pipe->AuxillerySpine.getValue()) { - auto* svp = doc->getViewProvider(pipe->AuxillerySpine.getValue()); - svp->setVisible(auxSpineShow); - auxSpineShow = false; + //make sure the user sees al important things: the base feature to select edges and the + //spine/auxilliary spine he already selected + if (pipe->AuxillerySpine.getValue()) { + auto* svp = doc->getViewProvider(pipe->AuxillerySpine.getValue()); + svp->setVisible(auxSpineShow); + auxSpineShow = false; + } + + static_cast(vp)->highlightReferences(false, true); } - - static_cast(vp)->highlightReferences(false, true); } void TaskPipeOrientation::onOrientationChanged(int idx) {