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.
|
- Remember last selected export format.
|
||||||
- [smart-pattern/valentina#123] Error inside Save layout dialog.
|
- [smart-pattern/valentina#123] Error inside Save layout dialog.
|
||||||
- Improve error handling for the dxf export.
|
- 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
|
# Version 0.7.46 Mar 31, 2021
|
||||||
- Fix incorrect calculation of value for multisize measurements in Valentina.
|
- Fix incorrect calculation of value for multisize measurements in Valentina.
|
||||||
|
|
|
@ -34,6 +34,7 @@
|
||||||
#include "../ifc/exception/vexceptionemptyparameter.h"
|
#include "../ifc/exception/vexceptionemptyparameter.h"
|
||||||
#include "../ifc/exception/vexceptionwrongid.h"
|
#include "../ifc/exception/vexceptionwrongid.h"
|
||||||
#include "../ifc/exception/vexceptionundo.h"
|
#include "../ifc/exception/vexceptionundo.h"
|
||||||
|
#include "../ifc/exception/vexceptioninvalidhistory.h"
|
||||||
#include "version.h"
|
#include "version.h"
|
||||||
#include "core/vapplication.h"
|
#include "core/vapplication.h"
|
||||||
#include "../vmisc/customevents.h"
|
#include "../vmisc/customevents.h"
|
||||||
|
@ -4819,11 +4820,18 @@ void MainWindow::CreateActions()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
VPatternRecipe recipe(doc);
|
try
|
||||||
QString error;
|
|
||||||
if (not recipe.SaveDocument(fileName, error))
|
|
||||||
{
|
{
|
||||||
qCWarning(vMainWindow, "%s", qUtf8Printable(tr("Could not save recipe. %1").arg(error)));
|
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())));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -41,7 +41,7 @@
|
||||||
* @param error string with error
|
* @param error string with error
|
||||||
*/
|
*/
|
||||||
VException::VException(const QString &error) V_NOEXCEPT_EXPR (true)
|
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");
|
Q_ASSERT_X(not error.isEmpty(), Q_FUNC_INFO, "Error message is empty");
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,7 +64,7 @@ protected:
|
||||||
QString error;
|
QString error;
|
||||||
|
|
||||||
/** @brief moreInfo more information about error */
|
/** @brief moreInfo more information about error */
|
||||||
QString moreInfo;
|
QString moreInfo {};
|
||||||
|
|
||||||
QString MoreInfo(const QString &detInfo) const;
|
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
|
SetAttribute(recipeFinalMeasurement, QStringLiteral("formula"), fm.formula); // TODO: localize
|
||||||
|
|
||||||
QScopedPointer<Calculator> cal(new Calculator());
|
QScopedPointer<Calculator> cal(new Calculator());
|
||||||
const qreal result = cal->EvalFormula(data.DataVariables(), fm.formula);
|
try
|
||||||
if (qIsInf(result) || qIsNaN(result))
|
|
||||||
{
|
{
|
||||||
const QString errorMsg = QString("%1\n\n%1").arg(tr("Reading final measurements error."),
|
const qreal result = cal->EvalFormula(data.DataVariables(), fm.formula);
|
||||||
tr("Value for final measurtement '%1' is infinite or NaN. "
|
if (qIsInf(result) || qIsNaN(result))
|
||||||
"Please, check your calculations.").arg(fm.name));
|
{
|
||||||
VAbstractApplication::VApp()->IsPedantic() ? throw VException(errorMsg) :
|
const QString errorMsg = QString("%1\n\n%1").arg(tr("Reading final measurements error."),
|
||||||
qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg;
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
SetAttribute(recipeFinalMeasurement, QStringLiteral("value"), result);
|
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;
|
return recipeFinalMeasurement;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user