PartDesign: fix task dressup/transformed creation cancel
This commit is contained in:
@@ -68,6 +68,9 @@ TaskDressUpParameters::TaskDressUpParameters(ViewProviderDressUp *DressUpView, b
|
||||
, allowFaces(selectFaces)
|
||||
, allowEdges(selectEdges)
|
||||
{
|
||||
// remember initial transaction ID
|
||||
App::GetApplication().getActiveTransaction(&transactionID);
|
||||
|
||||
selectionMode = none;
|
||||
showObject();
|
||||
}
|
||||
@@ -79,10 +82,16 @@ TaskDressUpParameters::~TaskDressUpParameters()
|
||||
}
|
||||
|
||||
void TaskDressUpParameters::setupTransaction() {
|
||||
if(!DressUpView)
|
||||
return;
|
||||
|
||||
int tid = 0;
|
||||
const char *name = App::GetApplication().getActiveTransaction(&tid);
|
||||
if(tid && tid == transactionID)
|
||||
return;
|
||||
|
||||
std::string n("Edit ");
|
||||
n += DressUpView->getObject()->Label.getValue();
|
||||
n += DressUpView->getObject()->getNameInDocument();
|
||||
if(!name || n != name)
|
||||
App::GetApplication().setActiveTransaction(n.c_str());
|
||||
}
|
||||
@@ -352,6 +361,11 @@ bool TaskDlgDressUpParameters::accept()
|
||||
bool TaskDlgDressUpParameters::reject()
|
||||
{
|
||||
getDressUpView()->highlightReferences(false);
|
||||
|
||||
auto editDoc = Gui::Application::Instance->editDocument();
|
||||
if(editDoc && parameter->getTransactionID())
|
||||
editDoc->getDocument()->undo(parameter->getTransactionID());
|
||||
|
||||
return TaskDlgFeatureParameters::reject();
|
||||
}
|
||||
|
||||
|
||||
@@ -59,6 +59,10 @@ public:
|
||||
/// Apply the changes made to the object to it
|
||||
virtual void apply() {};
|
||||
|
||||
int getTransactionID() const {
|
||||
return transactionID;
|
||||
}
|
||||
|
||||
protected Q_SLOTS:
|
||||
void onButtonRefAdd(const bool checked);
|
||||
void onButtonRefRemove(const bool checked);
|
||||
|
||||
@@ -80,6 +80,9 @@ TaskTransformedParameters::TaskTransformedParameters(ViewProviderTransformed *Tr
|
||||
Gui::Document* doc = TransformedView->getDocument();
|
||||
this->attachDocument(doc);
|
||||
}
|
||||
|
||||
// remember initial transaction ID
|
||||
App::GetApplication().getActiveTransaction(&transactionID);
|
||||
}
|
||||
|
||||
TaskTransformedParameters::TaskTransformedParameters(TaskMultiTransformParameters *parentTask)
|
||||
@@ -168,10 +171,17 @@ bool TaskTransformedParameters::originalSelected(const Gui::SelectionChanges& ms
|
||||
}
|
||||
|
||||
void TaskTransformedParameters::setupTransaction() {
|
||||
auto obj = getObject();
|
||||
if(!obj)
|
||||
return;
|
||||
|
||||
int tid = 0;
|
||||
const char *name = App::GetApplication().getActiveTransaction(&tid);
|
||||
if(tid && tid == transactionID)
|
||||
return;
|
||||
|
||||
std::string n("Edit ");
|
||||
n += getObject()->Label.getValue();
|
||||
n += obj->getNameInDocument();
|
||||
if(!name || n != name)
|
||||
App::GetApplication().setActiveTransaction(n.c_str());
|
||||
}
|
||||
@@ -418,6 +428,10 @@ bool TaskDlgTransformedParameters::reject()
|
||||
// ensure that we are not in selection mode
|
||||
parameter->exitSelectionMode();
|
||||
|
||||
auto editDoc = Gui::Application::Instance->editDocument();
|
||||
if(editDoc && parameter->getTransactionID())
|
||||
editDoc->getDocument()->undo(parameter->getTransactionID());
|
||||
|
||||
return TaskDlgFeatureParameters::reject ();
|
||||
}
|
||||
|
||||
|
||||
@@ -143,6 +143,11 @@ public:
|
||||
virtual void apply() = 0;
|
||||
|
||||
void setupTransaction();
|
||||
|
||||
int getTransactionID() const {
|
||||
return transactionID;
|
||||
}
|
||||
|
||||
protected Q_SLOTS:
|
||||
/**
|
||||
* Returns the base transformation view provider
|
||||
@@ -205,6 +210,7 @@ protected:
|
||||
protected:
|
||||
QWidget* proxy;
|
||||
ViewProviderTransformed *TransformedView;
|
||||
int transactionID = 0;
|
||||
|
||||
enum selectionModes { none, addFeature, removeFeature, reference };
|
||||
selectionModes selectionMode;
|
||||
|
||||
Reference in New Issue
Block a user