Fix correct handle a final measurement formula error when exporting a pattern recipe.
Valentina must not crash.
This commit is contained in:
parent
2efe887cad
commit
abdebbbfaa
|
@ -8,6 +8,7 @@
|
|||
- Remember last selected export format.
|
||||
- [smart-pattern/valentina#123] Error inside Save layout dialog.
|
||||
- Improve error handling for the dxf export.
|
||||
- Fix correct handle a final measurement formula error when exporting a pattern recipe.
|
||||
|
||||
# Version 0.7.46 Mar 31, 2021
|
||||
- Fix incorrect calculation of value for multisize measurements in Valentina.
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
#include "../ifc/exception/vexceptionemptyparameter.h"
|
||||
#include "../ifc/exception/vexceptionwrongid.h"
|
||||
#include "../ifc/exception/vexceptionundo.h"
|
||||
#include "../ifc/exception/vexceptioninvalidhistory.h"
|
||||
#include "version.h"
|
||||
#include "core/vapplication.h"
|
||||
#include "../vmisc/customevents.h"
|
||||
|
@ -4819,12 +4820,19 @@ void MainWindow::CreateActions()
|
|||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
VPatternRecipe recipe(doc);
|
||||
QString error;
|
||||
if (not recipe.SaveDocument(fileName, error))
|
||||
{
|
||||
qCWarning(vMainWindow, "%s", qUtf8Printable(tr("Could not save recipe. %1").arg(error)));
|
||||
}
|
||||
}
|
||||
catch (const VExceptionInvalidHistory &e)
|
||||
{
|
||||
qCCritical(vMainWindow, "%s", qUtf8Printable(tr("Could not create recipe file. %1").arg(e.ErrorMessage())));
|
||||
}
|
||||
});
|
||||
|
||||
connect(ui->actionNewDraw, &QAction::triggered, this, [this]()
|
||||
|
|
|
@ -41,7 +41,7 @@
|
|||
* @param error string with error
|
||||
*/
|
||||
VException::VException(const QString &error) V_NOEXCEPT_EXPR (true)
|
||||
:QException(), error(error), moreInfo(QString())
|
||||
: error(error)
|
||||
{
|
||||
Q_ASSERT_X(not error.isEmpty(), Q_FUNC_INFO, "Error message is empty");
|
||||
}
|
||||
|
|
|
@ -64,7 +64,7 @@ protected:
|
|||
QString error;
|
||||
|
||||
/** @brief moreInfo more information about error */
|
||||
QString moreInfo;
|
||||
QString moreInfo {};
|
||||
|
||||
QString MoreInfo(const QString &detInfo) const;
|
||||
};
|
||||
|
|
|
@ -435,17 +435,26 @@ QDomElement VPatternRecipe::FinalMeasurement(const VFinalMeasurement &fm, const
|
|||
SetAttribute(recipeFinalMeasurement, QStringLiteral("formula"), fm.formula); // TODO: localize
|
||||
|
||||
QScopedPointer<Calculator> cal(new Calculator());
|
||||
try
|
||||
{
|
||||
const qreal result = cal->EvalFormula(data.DataVariables(), fm.formula);
|
||||
if (qIsInf(result) || qIsNaN(result))
|
||||
{
|
||||
const QString errorMsg = QString("%1\n\n%1").arg(tr("Reading final measurements error."),
|
||||
tr("Value for final measurtement '%1' is infinite or NaN. "
|
||||
"Please, check your calculations.").arg(fm.name));
|
||||
VAbstractApplication::VApp()->IsPedantic() ? throw VException(errorMsg) :
|
||||
qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg;
|
||||
VAbstractApplication::VApp()->IsPedantic() ? throw VException(errorMsg)
|
||||
: qWarning()
|
||||
<< VAbstractValApplication::warningMessageSignature + errorMsg;
|
||||
}
|
||||
|
||||
SetAttribute(recipeFinalMeasurement, QStringLiteral("value"), result);
|
||||
}
|
||||
catch (const qmu::QmuParserError &e)
|
||||
{
|
||||
throw VExceptionInvalidHistory(tr("Unable to create record for final measurement '%1'. Error: %2")
|
||||
.arg(fm.name).arg(e.GetMsg()));
|
||||
}
|
||||
|
||||
return recipeFinalMeasurement;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user