Part: [skip ci] properly handle transactions when editing primitives
This commit is contained in:
@@ -1107,16 +1107,21 @@ void DlgPrimitives::accept(const QString& placement)
|
||||
.arg(placement);
|
||||
}
|
||||
|
||||
// store command for undo
|
||||
QString cmd = tr("Edit %1").arg(QString::fromUtf8(featurePtr->Label.getValue()));
|
||||
doc->openTransaction(cmd.toLatin1());
|
||||
// execute command
|
||||
// execute command, a transaction is already opened
|
||||
Gui::Command::runCommand(Gui::Command::App, command.toLatin1());
|
||||
doc->recompute();
|
||||
// commit undo command
|
||||
doc->commitTransaction();
|
||||
}
|
||||
|
||||
void DlgPrimitives::reject()
|
||||
{
|
||||
if (featurePtr.expired())
|
||||
return;
|
||||
App::Document* doc = featurePtr->getDocument();
|
||||
doc->abortTransaction();
|
||||
}
|
||||
|
||||
void DlgPrimitives::onChangePlane(QWidget*)
|
||||
{
|
||||
|
||||
@@ -1438,16 +1443,10 @@ TaskPrimitivesEdit::~TaskPrimitivesEdit()
|
||||
|
||||
QDialogButtonBox::StandardButtons TaskPrimitivesEdit::getStandardButtons() const
|
||||
{
|
||||
return QDialogButtonBox::Close |
|
||||
return QDialogButtonBox::Cancel |
|
||||
QDialogButtonBox::Ok;
|
||||
}
|
||||
|
||||
void TaskPrimitivesEdit::modifyStandardButtons(QDialogButtonBox* box)
|
||||
{
|
||||
QPushButton* btn = box->button(QDialogButtonBox::Ok);
|
||||
btn->setText(QApplication::translate("PartGui::DlgPrimitives", "&OK"));
|
||||
}
|
||||
|
||||
bool TaskPrimitivesEdit::accept()
|
||||
{
|
||||
widget->accept(location->toPlacement());
|
||||
@@ -1458,6 +1457,7 @@ bool TaskPrimitivesEdit::accept()
|
||||
|
||||
bool TaskPrimitivesEdit::reject()
|
||||
{
|
||||
widget->reject();
|
||||
std::string document = getDocumentName(); // needed because resetEdit() deletes this instance
|
||||
Gui::Command::doCommand(Gui::Command::Gui, "Gui.getDocument('%s').resetEdit()", document.c_str());
|
||||
return true;
|
||||
|
||||
@@ -70,6 +70,7 @@ public:
|
||||
~DlgPrimitives();
|
||||
void createPrimitive(const QString&);
|
||||
void accept(const QString&);
|
||||
void reject();
|
||||
|
||||
private Q_SLOTS:
|
||||
void on_buttonCircleFromThreePoints_clicked();
|
||||
@@ -149,7 +150,6 @@ public:
|
||||
bool accept();
|
||||
bool reject();
|
||||
QDialogButtonBox::StandardButtons getStandardButtons() const;
|
||||
void modifyStandardButtons(QDialogButtonBox*);
|
||||
|
||||
private:
|
||||
DlgPrimitives* widget;
|
||||
|
||||
Reference in New Issue
Block a user