From 6b29b8c5289424fe0c434b648f369a193aac0bff Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Tue, 8 Aug 2017 11:51:06 +0300 Subject: [PATCH] Fix method DialogIncrements::IncrementUsed. Checking regular text in expression is not enough to know that an increment was used. --HG-- branch : develop --- src/app/valentina/dialogs/dialogincrements.cpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/app/valentina/dialogs/dialogincrements.cpp b/src/app/valentina/dialogs/dialogincrements.cpp index 559aea1a0..b63d04664 100644 --- a/src/app/valentina/dialogs/dialogincrements.cpp +++ b/src/app/valentina/dialogs/dialogincrements.cpp @@ -31,6 +31,7 @@ #include "../vwidgets/vwidgetpopup.h" #include "../vmisc/vsettings.h" #include "../qmuparser/qmudef.h" +#include "../qmuparser/qmutokenparser.h" #include "../vpatterndb/vtranslatevars.h" #include "../vpatterndb/calculator.h" #include "../vtools/dialogs/support/dialogeditwrongformula.h" @@ -491,7 +492,21 @@ bool DialogIncrements::IncrementUsed(const QString &name) const { if (expressions.at(i).indexOf(name) != -1) { - return true; + // Eval formula + try + { + QScopedPointer cal(new qmu::QmuTokenParser(expressions.at(i), false, false)); + + // Tokens (variables, measurements) + if (cal->GetTokens().values().contains(name)) + { + return true; + } + } + catch (const qmu::QmuParserError &) + { + // Do nothing. Because we not sure if used. A formula is broken. + } } } return false;