fix crash when pressing cancel on pipe task panel

This commit is contained in:
wmayer 2017-01-24 15:00:41 +01:00
parent d9dda3fa1d
commit bebda4c6ad

View File

@ -67,7 +67,7 @@ using namespace Gui;
// Task Parameter // 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")) : TaskSketchBasedParameters(PipeView, parent, "PartDesign_Additive_Pipe",tr("Pipe parameters"))
{ {
// we need a separate container widget to add all controls to // we need a separate container widget to add all controls to
@ -88,11 +88,11 @@ TaskPipeParameters::TaskPipeParameters(ViewProviderPipe *PipeView,bool /*newObj*
this->groupLayout()->addWidget(proxy); this->groupLayout()->addWidget(proxy);
PartDesign::Pipe* pipe = static_cast<PartDesign::Pipe*>(PipeView->getObject()); PartDesign::Pipe* pipe = static_cast<PartDesign::Pipe*>(PipeView->getObject());
Gui::Document* doc = Gui::Application::Instance->activeDocument(); Gui::Document* doc = PipeView->getDocument();
//make sure th euser sees al important things: the //make sure the user sees all important things: the
//spine/auxillery spine he already selected //spine/auxilliary spine he already selected
if(pipe->Spine.getValue()) { if (pipe->Spine.getValue()) {
auto* svp = doc->getViewProvider(pipe->Spine.getValue()); auto* svp = doc->getViewProvider(pipe->Spine.getValue());
spineShow = svp->isShow(); spineShow = svp->isShow();
svp->setVisible(true); svp->setVisible(true);
@ -151,17 +151,20 @@ void TaskPipeParameters::onSelectionChanged(const Gui::SelectionChanges& msg)
TaskPipeParameters::~TaskPipeParameters() TaskPipeParameters::~TaskPipeParameters()
{ {
if (vp) {
PartDesign::Pipe* pipe = static_cast<PartDesign::Pipe*>(vp->getObject()); PartDesign::Pipe* pipe = static_cast<PartDesign::Pipe*>(vp->getObject());
Gui::Document* doc = Gui::Application::Instance->activeDocument(); Gui::Document* doc = vp->getDocument();
//make sure th euser sees al important things: the //make sure the user sees all important things: the
//spine/auxillery spine he already selected //spine/auxilliary spine he already selected
if(pipe->Spine.getValue()) { if (pipe->Spine.getValue()) {
auto* svp = doc->getViewProvider(pipe->Spine.getValue()); auto* svp = doc->getViewProvider(pipe->Spine.getValue());
svp->setVisible(spineShow); svp->setVisible(spineShow);
spineShow = false; spineShow = false;
} }
static_cast<ViewProviderPipe*>(vp)->highlightReferences(false, false); static_cast<ViewProviderPipe*>(vp)->highlightReferences(false, false);
}
delete ui; delete ui;
} }
@ -340,20 +343,22 @@ TaskPipeOrientation::TaskPipeOrientation(ViewProviderPipe* PipeView, bool /*newO
updateUI(pipe->Mode.getValue()); updateUI(pipe->Mode.getValue());
} }
TaskPipeOrientation::~TaskPipeOrientation() { TaskPipeOrientation::~TaskPipeOrientation()
{
if (vp) {
PartDesign::Pipe* pipe = static_cast<PartDesign::Pipe*>(vp->getObject()); PartDesign::Pipe* pipe = static_cast<PartDesign::Pipe*>(vp->getObject());
Gui::Document* doc = Gui::Application::Instance->activeDocument(); Gui::Document* doc = vp->getDocument();
//make sure th euser sees al important things: the base feature to select edges and the //make sure the user sees al important things: the base feature to select edges and the
//spine/auxillery spine he already selected //spine/auxilliary spine he already selected
if(pipe->AuxillerySpine.getValue()) { if (pipe->AuxillerySpine.getValue()) {
auto* svp = doc->getViewProvider(pipe->AuxillerySpine.getValue()); auto* svp = doc->getViewProvider(pipe->AuxillerySpine.getValue());
svp->setVisible(auxSpineShow); svp->setVisible(auxSpineShow);
auxSpineShow = false; auxSpineShow = false;
} }
static_cast<ViewProviderPipe*>(vp)->highlightReferences(false, true); static_cast<ViewProviderPipe*>(vp)->highlightReferences(false, true);
}
} }
void TaskPipeOrientation::onOrientationChanged(int idx) { void TaskPipeOrientation::onOrientationChanged(int idx) {