Fix method DialogIncrements::IncrementUsed.

Checking regular text in expression is not enough to know that an increment was
used.

--HG--
branch : develop
This commit is contained in:
Roman Telezhynskyi 2017-08-08 11:51:06 +03:00
parent 372ab02bbc
commit 6b29b8c528

View File

@ -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<qmu::QmuTokenParser> 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;