+ fix crash on abort of adding primitives
This commit is contained in:
parent
b08a75bfb2
commit
6b4821a855
|
@ -29,6 +29,7 @@
|
||||||
# include <QTextStream>
|
# include <QTextStream>
|
||||||
# include <QMessageBox>
|
# include <QMessageBox>
|
||||||
# include <Precision.hxx>
|
# include <Precision.hxx>
|
||||||
|
# include <boost/bind.hpp>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <Base/Console.h>
|
#include <Base/Console.h>
|
||||||
|
@ -225,14 +226,52 @@ TaskDatumParameters::TaskDatumParameters(ViewProviderDatum *DatumView,QWidget *p
|
||||||
Base::Console().Error ("%s\n", ex.what () );
|
Base::Console().Error ("%s\n", ex.what () );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pcDatum->Support.getSize() == 0)
|
if (pcDatum->Support.getSize() == 0)
|
||||||
autoNext = true;
|
autoNext = true;
|
||||||
else
|
else
|
||||||
autoNext = false;
|
autoNext = false;
|
||||||
|
|
||||||
DatumView->setPickable(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)
|
const QString makeHintText(std::set<eRefType> hint)
|
||||||
{
|
{
|
||||||
|
@ -737,26 +776,6 @@ bool TaskDatumParameters::getFlip() const
|
||||||
return ui->checkBoxFlip->isChecked();
|
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)
|
void TaskDatumParameters::changeEvent(QEvent *e)
|
||||||
{
|
{
|
||||||
TaskBox::changeEvent(e);
|
TaskBox::changeEvent(e);
|
||||||
|
|
|
@ -89,6 +89,8 @@ protected:
|
||||||
void changeEvent(QEvent *e);
|
void changeEvent(QEvent *e);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void resetViewMode();
|
||||||
|
void objectDeleted(const Gui::ViewProviderDocumentObject&);
|
||||||
void onSelectionChanged(const Gui::SelectionChanges& msg);
|
void onSelectionChanged(const Gui::SelectionChanges& msg);
|
||||||
void updateUI(std::string message = std::string(), bool isWarning = false);
|
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.
|
std::vector<Attacher::eMapMode> modesInList; //this list is synchronous to what is populated into listOfModes widget.
|
||||||
bool completed;
|
bool completed;
|
||||||
|
|
||||||
|
typedef boost::BOOST_SIGNALS_NAMESPACE::connection Connection;
|
||||||
|
Connection connectDelObject;
|
||||||
};
|
};
|
||||||
|
|
||||||
/// simulation dialog for the TaskView
|
/// simulation dialog for the TaskView
|
||||||
|
|
|
@ -658,11 +658,12 @@ bool TaskPrimitiveParameters::accept()
|
||||||
vp->setVisible(cs_visibility);
|
vp->setVisible(cs_visibility);
|
||||||
|
|
||||||
connection.disconnect();
|
connection.disconnect();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TaskPrimitiveParameters::reject() {
|
bool TaskPrimitiveParameters::reject()
|
||||||
|
{
|
||||||
// roll back the done things
|
// roll back the done things
|
||||||
Gui::Command::abortCommand();
|
Gui::Command::abortCommand();
|
||||||
Gui::Command::doCommand(Gui::Command::Gui,"Gui.activeDocument().resetEdit()");
|
Gui::Command::doCommand(Gui::Command::Gui,"Gui.activeDocument().resetEdit()");
|
||||||
|
@ -675,6 +676,7 @@ bool TaskPrimitiveParameters::reject() {
|
||||||
vp->setVisible(cs_visibility);
|
vp->setVisible(cs_visibility);
|
||||||
|
|
||||||
connection.disconnect();
|
connection.disconnect();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user