+ fix crash on abort of adding primitives
This commit is contained in:
parent
b08a75bfb2
commit
6b4821a855
|
@ -29,6 +29,7 @@
|
|||
# include <QTextStream>
|
||||
# include <QMessageBox>
|
||||
# include <Precision.hxx>
|
||||
# include <boost/bind.hpp>
|
||||
#endif
|
||||
|
||||
#include <Base/Console.h>
|
||||
|
@ -214,8 +215,8 @@ TaskDatumParameters::TaskDatumParameters(ViewProviderDatum *DatumView,QWidget *p
|
|||
updateListOfModes(eMapMode(pcDatum->MapMode.getValue()));
|
||||
|
||||
//temporary show coordinate systems for selection
|
||||
PartDesign::Body * body = PartDesign::Body::findBodyOf ( DatumView->getObject() );
|
||||
if(body) {
|
||||
PartDesign::Body * body = PartDesign::Body::findBodyOf(DatumView->getObject());
|
||||
if (body) {
|
||||
try {
|
||||
App::Origin *origin = body->getOrigin();
|
||||
ViewProviderOrigin* vpOrigin;
|
||||
|
@ -225,14 +226,52 @@ TaskDatumParameters::TaskDatumParameters(ViewProviderDatum *DatumView,QWidget *p
|
|||
Base::Console().Error ("%s\n", ex.what () );
|
||||
}
|
||||
}
|
||||
|
||||
if (pcDatum->Support.getSize() == 0)
|
||||
autoNext = true;
|
||||
else
|
||||
autoNext = false;
|
||||
|
||||
|
||||
DatumView->setPickable(false);
|
||||
|
||||
// connect object deletion with slot
|
||||
auto bnd = boost::bind(&TaskDatumParameters::objectDeleted, this, _1);
|
||||
Gui::Document* document = Gui::Application::Instance->getDocument(DatumView->getObject()->getDocument());
|
||||
connectDelObject = document->signalDeletedObject.connect(bnd);
|
||||
}
|
||||
|
||||
TaskDatumParameters::~TaskDatumParameters()
|
||||
{
|
||||
connectDelObject.disconnect();
|
||||
if (DatumView)
|
||||
resetViewMode();
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void TaskDatumParameters::resetViewMode()
|
||||
{
|
||||
//end temporary view mode of coordinate system
|
||||
PartDesign::Body * body = PartDesign::Body::findBodyOf(DatumView->getObject());
|
||||
if (body) {
|
||||
try {
|
||||
App::Origin *origin = body->getOrigin();
|
||||
ViewProviderOrigin* vpOrigin;
|
||||
vpOrigin = static_cast<ViewProviderOrigin*>(Gui::Application::Instance->getViewProvider(origin));
|
||||
vpOrigin->resetTemporaryVisibility();
|
||||
}
|
||||
catch (const Base::Exception &ex) {
|
||||
Base::Console().Error("%s\n", ex.what());
|
||||
}
|
||||
}
|
||||
|
||||
DatumView->setPickable(true);
|
||||
}
|
||||
|
||||
void TaskDatumParameters::objectDeleted(const Gui::ViewProviderDocumentObject& view)
|
||||
{
|
||||
if (DatumView == &view)
|
||||
DatumView = nullptr;
|
||||
}
|
||||
|
||||
const QString makeHintText(std::set<eRefType> hint)
|
||||
{
|
||||
|
@ -737,26 +776,6 @@ bool TaskDatumParameters::getFlip() const
|
|||
return ui->checkBoxFlip->isChecked();
|
||||
}
|
||||
|
||||
TaskDatumParameters::~TaskDatumParameters()
|
||||
{
|
||||
//end temporary view mode of coordinate system
|
||||
PartDesign::Body * body = PartDesign::Body::findBodyOf ( DatumView->getObject() );
|
||||
if(body) {
|
||||
try {
|
||||
App::Origin *origin = body->getOrigin();
|
||||
ViewProviderOrigin* vpOrigin;
|
||||
vpOrigin = static_cast<ViewProviderOrigin*>(Gui::Application::Instance->getViewProvider(origin));
|
||||
vpOrigin->resetTemporaryVisibility();
|
||||
} catch (const Base::Exception &ex) {
|
||||
Base::Console().Error ("%s\n", ex.what () );
|
||||
}
|
||||
}
|
||||
|
||||
DatumView->setPickable(true);
|
||||
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void TaskDatumParameters::changeEvent(QEvent *e)
|
||||
{
|
||||
TaskBox::changeEvent(e);
|
||||
|
|
|
@ -89,6 +89,8 @@ protected:
|
|||
void changeEvent(QEvent *e);
|
||||
|
||||
private:
|
||||
void resetViewMode();
|
||||
void objectDeleted(const Gui::ViewProviderDocumentObject&);
|
||||
void onSelectionChanged(const Gui::SelectionChanges& msg);
|
||||
void updateUI(std::string message = std::string(), bool isWarning = false);
|
||||
|
||||
|
@ -117,6 +119,8 @@ private:
|
|||
std::vector<Attacher::eMapMode> modesInList; //this list is synchronous to what is populated into listOfModes widget.
|
||||
bool completed;
|
||||
|
||||
typedef boost::BOOST_SIGNALS_NAMESPACE::connection Connection;
|
||||
Connection connectDelObject;
|
||||
};
|
||||
|
||||
/// simulation dialog for the TaskView
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
# include <QTextStream>
|
||||
# include <QMessageBox>
|
||||
# include <Precision.hxx>
|
||||
#include <boost/bind/bind.hpp>
|
||||
# include <boost/bind/bind.hpp>
|
||||
#endif
|
||||
|
||||
#include "TaskPrimitiveParameters.h"
|
||||
|
@ -624,10 +624,10 @@ TaskPrimitiveParameters::TaskPrimitiveParameters(ViewProviderPrimitive* Primitiv
|
|||
|
||||
parameter = new TaskDatumParameters(vp);
|
||||
Content.push_back(parameter);
|
||||
|
||||
|
||||
primitive = new TaskBoxPrimitives(PrimitiveView);
|
||||
Content.push_back(primitive);
|
||||
|
||||
|
||||
//make sure we track changes from the coordinate system to the primitive position
|
||||
auto bnd = boost::bind(&TaskPrimitiveParameters::objectChanged, this, _1, _2);
|
||||
connection = vp_prm->getObject()->getDocument()->signalChangedObject.connect(bnd);
|
||||
|
@ -656,25 +656,27 @@ bool TaskPrimitiveParameters::accept()
|
|||
ViewProviderDatumCoordinateSystem* vp = static_cast<ViewProviderDatumCoordinateSystem*>(
|
||||
Gui::Application::Instance->activeDocument()->getViewProvider(cs));
|
||||
vp->setVisible(cs_visibility);
|
||||
|
||||
connection.disconnect();
|
||||
|
||||
connection.disconnect();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TaskPrimitiveParameters::reject() {
|
||||
|
||||
bool TaskPrimitiveParameters::reject()
|
||||
{
|
||||
// roll back the done things
|
||||
Gui::Command::abortCommand();
|
||||
Gui::Command::doCommand(Gui::Command::Gui,"Gui.activeDocument().resetEdit()");
|
||||
|
||||
|
||||
//if we did not delete the document object we need to set the visibilities right
|
||||
ViewProviderDatumCoordinateSystem* vp = static_cast<ViewProviderDatumCoordinateSystem*>(
|
||||
Gui::Application::Instance->activeDocument()->getViewProvider(cs));
|
||||
|
||||
if(vp)
|
||||
Gui::Application::Instance->activeDocument()->getViewProvider(cs));
|
||||
|
||||
if (vp)
|
||||
vp->setVisible(cs_visibility);
|
||||
|
||||
|
||||
connection.disconnect();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -58,7 +58,7 @@ public:
|
|||
~TaskBoxPrimitives();
|
||||
|
||||
void setPrimitive(QString name);
|
||||
|
||||
|
||||
public Q_SLOTS:
|
||||
void onBoxLengthChanged(double);
|
||||
void onBoxWidthChanged(double);
|
||||
|
@ -120,8 +120,8 @@ protected:
|
|||
|
||||
virtual bool accept();
|
||||
virtual bool reject();
|
||||
|
||||
private:
|
||||
|
||||
private:
|
||||
s::connection connection;
|
||||
TaskBoxPrimitives* primitive;
|
||||
TaskDatumParameters* parameter;
|
||||
|
|
Loading…
Reference in New Issue
Block a user