Fix correct handle a final measurement formula error when exporting a pattern recipe.
Valentina must not crash.
(cherry picked from commit abdebbbfaa
)
This commit is contained in:
parent
662ffd255b
commit
40af5ce356
|
@ -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"
|
||||||
|
@ -4974,12 +4975,19 @@ void MainWindow::CreateActions()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
VPatternRecipe recipe(doc);
|
VPatternRecipe recipe(doc);
|
||||||
QString error;
|
QString error;
|
||||||
if (not recipe.SaveDocument(fileName, error))
|
if (not recipe.SaveDocument(fileName, error))
|
||||||
{
|
{
|
||||||
qCWarning(vMainWindow, "%s", qUtf8Printable(tr("Could not save recipe. %1").arg(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]()
|
connect(ui->actionNewDraw, &QAction::triggered, this, [this]()
|
||||||
|
|
|
@ -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());
|
||||||
|
try
|
||||||
|
{
|
||||||
const qreal result = cal->EvalFormula(data.DataVariables(), fm.formula);
|
const qreal result = cal->EvalFormula(data.DataVariables(), fm.formula);
|
||||||
if (qIsInf(result) || qIsNaN(result))
|
if (qIsInf(result) || qIsNaN(result))
|
||||||
{
|
{
|
||||||
const QString errorMsg = QString("%1\n\n%1").arg(tr("Reading final measurements error."),
|
const QString errorMsg = QString("%1\n\n%1").arg(tr("Reading final measurements error."),
|
||||||
tr("Value for final measurtement '%1' is infinite or NaN. "
|
tr("Value for final measurtement '%1' is infinite or NaN. "
|
||||||
"Please, check your calculations.").arg(fm.name));
|
"Please, check your calculations.").arg(fm.name));
|
||||||
VAbstractApplication::VApp()->IsPedantic() ? throw VException(errorMsg) :
|
VAbstractApplication::VApp()->IsPedantic() ? throw VException(errorMsg)
|
||||||
qWarning() << VAbstractValApplication::warningMessageSignature + 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