+ 0000454: Illegal storage access crash when canceling pad

+ live update of changes on pad task panel

git-svn-id: https://free-cad.svn.sourceforge.net/svnroot/free-cad/trunk@5053 e8eeb9e2-ec13-0410-a4a9-efa5cf37419d
This commit is contained in:
wmayer 2011-10-22 11:56:38 +00:00
parent 87dd7826c7
commit d6a0e3cf14
2 changed files with 39 additions and 10 deletions

View File

@ -29,6 +29,7 @@
#include "ui_TaskPadParameters.h"
#include "TaskPadParameters.h"
#include <App/Application.h>
#include <App/Document.h>
#include <Gui/Application.h>
#include <Gui/Document.h>
#include <Gui/BitmapFactory.h>
@ -55,6 +56,13 @@ TaskPadParameters::TaskPadParameters(ViewProviderPad *PadView,QWidget *parent)
ui->setupUi(proxy);
QMetaObject::connectSlotsByName(this);
connect(ui->doubleSpinBox, SIGNAL(valueChanged(double)),
this, SLOT(onLengthChanged(double)));
connect(ui->checkBoxMirrored, SIGNAL(toggled(bool)),
this, SLOT(onMirrored(bool)));
connect(ui->checkBoxReversed, SIGNAL(toggled(bool)),
this, SLOT(onReversed(bool)));
this->groupLayout()->addWidget(proxy);
PartDesign::Pad* pcPad = static_cast<PartDesign::Pad*>(PadView->getObject());
@ -68,22 +76,41 @@ TaskPadParameters::TaskPadParameters(ViewProviderPad *PadView,QWidget *parent)
// check if the sketch has support
Sketcher::SketchObject *pcSketch;
if(pcPad->Sketch.getValue() ){
pcSketch = static_cast<Sketcher::SketchObject*>(pcPad->Sketch.getValue());
if(pcSketch->Support.getValue() )
if (pcPad->Sketch.getValue()) {
pcSketch = static_cast<Sketcher::SketchObject*>(pcPad->Sketch.getValue());
if (pcSketch->Support.getValue())
// in case of sketch with support, reverse makes no sense (goes into the part)
ui->checkBoxReversed->setEnabled(0);
else
ui->checkBoxReversed->setChecked(reversed);
}
ui->checkBoxReversed->setChecked(reversed);
setFocus ();
}
void TaskPadParameters::onLengthChanged(double len)
{
PartDesign::Pad* pcPad = static_cast<PartDesign::Pad*>(PadView->getObject());
pcPad->Length.setValue((float)len);
pcPad->getDocument()->recomputeFeature(pcPad);
}
void TaskPadParameters::onMirrored(bool on)
{
PartDesign::Pad* pcPad = static_cast<PartDesign::Pad*>(PadView->getObject());
pcPad->MirroredExtent.setValue(on);
pcPad->getDocument()->recomputeFeature(pcPad);
}
void TaskPadParameters::onReversed(bool on)
{
PartDesign::Pad* pcPad = static_cast<PartDesign::Pad*>(PadView->getObject());
pcPad->Reversed.setValue(on);
pcPad->getDocument()->recomputeFeature(pcPad);
}
double TaskPadParameters::getLength(void) const
{
return ui->doubleSpinBox->value();
@ -165,7 +192,7 @@ bool TaskDlgPadParameters::reject()
PartDesign::Pad* pcPad = static_cast<PartDesign::Pad*>(PadView->getObject());
Sketcher::SketchObject *pcSketch;
App::DocumentObject *pcSupport;
if(pcPad->Sketch.getValue() ){
if (pcPad->Sketch.getValue()) {
pcSketch = static_cast<Sketcher::SketchObject*>(pcPad->Sketch.getValue());
pcSupport = pcSketch->Support.getValue();
}
@ -175,12 +202,11 @@ bool TaskDlgPadParameters::reject()
Gui::Command::doCommand(Gui::Command::Gui,"Gui.activeDocument().resetEdit()");
// if abort command deleted the object the support is visible again
if( ! Gui::Application::Instance->getViewProvider(pcPad) ){
if(pcSketch && Gui::Application::Instance->getViewProvider(pcSketch))
if (!Gui::Application::Instance->getViewProvider(pcPad)) {
if (pcSketch && Gui::Application::Instance->getViewProvider(pcSketch))
Gui::Application::Instance->getViewProvider(pcSketch)->show();
if(pcPad && Gui::Application::Instance->getViewProvider(pcSupport))
if (pcSupport && Gui::Application::Instance->getViewProvider(pcSupport))
Gui::Application::Instance->getViewProvider(pcSupport)->show();
}
//Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.recompute()");

View File

@ -57,6 +57,9 @@ public:
bool getMirroredExtent(void) const;
private Q_SLOTS:
void onLengthChanged(double);
void onMirrored(bool);
void onReversed(bool);
protected:
void changeEvent(QEvent *e);