Sketcher: Fix solver failure when setting datum results in wrong solver information
=================================================================================== fixes: https://forum.freecadweb.org/viewtopic.php?p=404945#p405014
This commit is contained in:
@@ -127,9 +127,9 @@ void EditDatumDialog::exec(bool atCursor)
|
||||
ui_ins_datum->labelEdit->selectNumber();
|
||||
ui_ins_datum->labelEdit->bind(sketch->Constraints.createPath(ConstrNbr));
|
||||
ui_ins_datum->name->setText(Base::Tools::fromStdString(Constr->Name));
|
||||
|
||||
|
||||
ui_ins_datum->cbDriving->setChecked(! Constr->isDriving);
|
||||
|
||||
|
||||
connect(ui_ins_datum->cbDriving, SIGNAL(toggled(bool)), this, SLOT(drivingToggled(bool)));
|
||||
connect(ui_ins_datum->labelEdit, SIGNAL(valueChanged(const Base::Quantity&)), this, SLOT(datumChanged()));
|
||||
connect(ui_ins_datum->labelEdit, SIGNAL(showFormulaDialog(bool)), this, SLOT(formEditorOpened(bool)));
|
||||
@@ -158,15 +158,15 @@ void EditDatumDialog::accepted()
|
||||
if (newQuant.isQuantity() || (Constr->Type == Sketcher::SnellsLaw && newQuant.isDimensionless())) {
|
||||
// save the value for the history
|
||||
ui_ins_datum->labelEdit->pushToHistory();
|
||||
|
||||
|
||||
double newDatum = newQuant.getValue();
|
||||
|
||||
|
||||
try {
|
||||
|
||||
|
||||
/*if (ui_ins_datum->cbDriving->isChecked() == Constr->isDriving) {
|
||||
Gui::cmdAppObjectArgs(sketch, "toggleDriving(%i)", ConstrNbr);
|
||||
}*/
|
||||
|
||||
|
||||
if (! ui_ins_datum->cbDriving->isChecked()) {
|
||||
if (ui_ins_datum->labelEdit->hasExpression())
|
||||
ui_ins_datum->labelEdit->apply();
|
||||
@@ -174,26 +174,30 @@ void EditDatumDialog::accepted()
|
||||
Gui::cmdAppObjectArgs(sketch, "setDatum(%i,App.Units.Quantity('%f %s'))",
|
||||
ConstrNbr, newDatum, (const char*)newQuant.getUnit().getString().toUtf8());
|
||||
}
|
||||
|
||||
|
||||
QString constraintName = ui_ins_datum->name->text().trimmed();
|
||||
if (Base::Tools::toStdString(constraintName) != sketch->Constraints[ConstrNbr]->Name) {
|
||||
std::string escapedstr = Base::Tools::escapedUnicodeFromUtf8(constraintName.toUtf8().constData());
|
||||
Gui::cmdAppObjectArgs(sketch, "renameConstraint(%d, u'%s')",
|
||||
ConstrNbr, escapedstr.c_str());
|
||||
}
|
||||
|
||||
|
||||
Gui::Command::commitCommand();
|
||||
|
||||
|
||||
if (sketch->noRecomputes && sketch->ExpressionEngine.depsAreTouched()) {
|
||||
sketch->ExpressionEngine.execute();
|
||||
sketch->solve();
|
||||
}
|
||||
|
||||
|
||||
tryAutoRecompute(sketch);
|
||||
}
|
||||
catch (const Base::Exception& e) {
|
||||
QMessageBox::critical(qApp->activeWindow(), QObject::tr("Dimensional constraint"), QString::fromUtf8(e.what()));
|
||||
Gui::Command::abortCommand();
|
||||
|
||||
if(sketch->noRecomputes) // if setdatum failed, it is highly likely that solver information is invalid.
|
||||
sketch->solve();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user