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
@ -84,15 +84,15 @@ TaskPipeParameters::TaskPipeParameters(ViewProviderPipe *PipeView,bool /*newObj*
this, SLOT(onButtonRefRemove(bool))); this, SLOT(onButtonRefRemove(bool)));
connect(ui->buttonProfileBase, SIGNAL(toggled(bool)), connect(ui->buttonProfileBase, SIGNAL(toggled(bool)),
this, SLOT(onBaseButton(bool))); this, SLOT(onBaseButton(bool)));
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);
@ -104,9 +104,9 @@ TaskPipeParameters::TaskPipeParameters(ViewProviderPipe *PipeView,bool /*newObj*
std::vector<std::string> strings = pipe->Spine.getSubValues(); std::vector<std::string> strings = pipe->Spine.getSubValues();
for (std::vector<std::string>::const_iterator i = strings.begin(); i != strings.end(); i++) for (std::vector<std::string>::const_iterator i = strings.begin(); i != strings.end(); i++)
ui->listWidgetReferences->addItem(QString::fromStdString(*i)); ui->listWidgetReferences->addItem(QString::fromStdString(*i));
ui->comboBoxTransition->setCurrentIndex(pipe->Transition.getValue()); ui->comboBoxTransition->setCurrentIndex(pipe->Transition.getValue());
updateUI(); updateUI();
} }
@ -151,18 +151,21 @@ void TaskPipeParameters::onSelectionChanged(const Gui::SelectionChanges& msg)
TaskPipeParameters::~TaskPipeParameters() TaskPipeParameters::~TaskPipeParameters()
{ {
PartDesign::Pipe* pipe = static_cast<PartDesign::Pipe*>(vp->getObject()); if (vp) {
Gui::Document* doc = Gui::Application::Instance->activeDocument(); PartDesign::Pipe* pipe = static_cast<PartDesign::Pipe*>(vp->getObject());
Gui::Document* doc = vp->getDocument();
//make sure th euser sees al important things: the
//spine/auxillery spine he already selected //make sure the user sees all important things: the
if(pipe->Spine.getValue()) { //spine/auxilliary spine he already selected
auto* svp = doc->getViewProvider(pipe->Spine.getValue()); if (pipe->Spine.getValue()) {
svp->setVisible(spineShow); auto* svp = doc->getViewProvider(pipe->Spine.getValue());
spineShow = false; svp->setVisible(spineShow);
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());
Gui::Document* doc = vp->getDocument();
PartDesign::Pipe* pipe = static_cast<PartDesign::Pipe*>(vp->getObject()); //make sure the user sees al important things: the base feature to select edges and the
Gui::Document* doc = Gui::Application::Instance->activeDocument(); //spine/auxilliary spine he already selected
if (pipe->AuxillerySpine.getValue()) {
//make sure th euser sees al important things: the base feature to select edges and the auto* svp = doc->getViewProvider(pipe->AuxillerySpine.getValue());
//spine/auxillery spine he already selected svp->setVisible(auxSpineShow);
if(pipe->AuxillerySpine.getValue()) { auxSpineShow = false;
auto* svp = doc->getViewProvider(pipe->AuxillerySpine.getValue()); }
svp->setVisible(auxSpineShow);
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) {