Fix potential memory leak.
--HG-- branch : develop
This commit is contained in:
parent
86f4b21879
commit
0467033855
|
@ -185,9 +185,9 @@ QStringList VAbstractPattern::ListMeasurements() const
|
||||||
const QStringList expressions = ListExpressions();
|
const QStringList expressions = ListExpressions();
|
||||||
for (int i=0; i < expressions.size(); ++i)
|
for (int i=0; i < expressions.size(); ++i)
|
||||||
{
|
{
|
||||||
qmu::QmuTokenParser *cal = new qmu::QmuTokenParser(expressions.at(i), false, false);// Eval formula
|
QScopedPointer<qmu::QmuTokenParser> cal(new qmu::QmuTokenParser(expressions.at(i), false, false));// Eval formula
|
||||||
const QMap<int, QString> tokens = cal->GetTokens();// Tokens (variables, measurements)
|
const QMap<int, QString> tokens = cal->GetTokens();// Tokens (variables, measurements)
|
||||||
delete cal;
|
delete cal.take();
|
||||||
|
|
||||||
const QList<QString> tValues = tokens.values();
|
const QList<QString> tValues = tokens.values();
|
||||||
for (int j = 0; j < tValues.size(); ++j)
|
for (int j = 0; j < tValues.size(); ++j)
|
||||||
|
|
|
@ -854,9 +854,9 @@ void VPatternConverter::ConvertPathPointExpressionsToV0_2_0(const QMap<QString,
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
QString VPatternConverter::FixMeasurementInFormulaToV0_2_0(const QString &formula, const QMap<QString, QString> &names)
|
QString VPatternConverter::FixMeasurementInFormulaToV0_2_0(const QString &formula, const QMap<QString, QString> &names)
|
||||||
{
|
{
|
||||||
qmu::QmuTokenParser *cal = new qmu::QmuTokenParser(formula, false, false);// Eval formula
|
QScopedPointer<qmu::QmuTokenParser> cal(new qmu::QmuTokenParser(formula, false, false));// Eval formula
|
||||||
QMap<int, QString> tokens = cal->GetTokens();// Tokens (variables, measurements)
|
QMap<int, QString> tokens = cal->GetTokens();// Tokens (variables, measurements)
|
||||||
delete cal;
|
delete cal.take();
|
||||||
|
|
||||||
QList<int> tKeys = tokens.keys();// Take all tokens positions
|
QList<int> tKeys = tokens.keys();// Take all tokens positions
|
||||||
QList<QString> tValues = tokens.values();
|
QList<QString> tValues = tokens.values();
|
||||||
|
|
|
@ -88,11 +88,11 @@ bool QmuTokenParser::IsSingle(const QString &formula)
|
||||||
return false;// if don't know say no
|
return false;// if don't know say no
|
||||||
}
|
}
|
||||||
|
|
||||||
QmuTokenParser *cal = new QmuTokenParser();
|
QScopedPointer<QmuTokenParser> cal(new QmuTokenParser());
|
||||||
|
|
||||||
// Parser doesn't know any variable on this stage. So, we just use variable factory that for each unknown
|
// Parser doesn't know any variable on this stage. So, we just use variable factory that for each unknown
|
||||||
// variable set value to 0.
|
// variable set value to 0.
|
||||||
cal->SetVarFactory(AddVariable, cal);
|
cal->SetVarFactory(AddVariable, cal.data());
|
||||||
cal->SetSepForEval();//Reset separators options
|
cal->SetSepForEval();//Reset separators options
|
||||||
|
|
||||||
try
|
try
|
||||||
|
@ -108,8 +108,7 @@ bool QmuTokenParser::IsSingle(const QString &formula)
|
||||||
|
|
||||||
QMap<int, QString> tokens = cal->GetTokens();// Tokens (variables, measurements)
|
QMap<int, QString> tokens = cal->GetTokens();// Tokens (variables, measurements)
|
||||||
const QMap<int, QString> numbers = cal->GetNumbers();// All numbers in expression
|
const QMap<int, QString> numbers = cal->GetNumbers();// All numbers in expression
|
||||||
|
delete cal.take();
|
||||||
delete cal;
|
|
||||||
|
|
||||||
// Remove "-" from tokens list if exist. If don't do that unary minus operation will broken.
|
// Remove "-" from tokens list if exist. If don't do that unary minus operation will broken.
|
||||||
RemoveAll(tokens, QStringLiteral("-"));
|
RemoveAll(tokens, QStringLiteral("-"));
|
||||||
|
|
|
@ -727,10 +727,10 @@ QString VTranslateVars::FormulaFromUser(const QString &formula, bool osSeparator
|
||||||
}
|
}
|
||||||
QString newFormula = formula;// Local copy for making changes
|
QString newFormula = formula;// Local copy for making changes
|
||||||
|
|
||||||
qmu::QmuTokenParser *cal = new qmu::QmuTokenParser(formula, osSeparator);// Eval formula
|
QScopedPointer<qmu::QmuTokenParser> cal(new qmu::QmuTokenParser(formula, osSeparator));// Eval formula
|
||||||
QMap<int, QString> tokens = cal->GetTokens();// Tokens (variables, measurements)
|
QMap<int, QString> tokens = cal->GetTokens();// Tokens (variables, measurements)
|
||||||
QMap<int, QString> numbers = cal->GetNumbers();// All numbers in expression for changing decimal separator
|
QMap<int, QString> numbers = cal->GetNumbers();// All numbers in expression for changing decimal separator
|
||||||
delete cal;
|
delete cal.take();
|
||||||
|
|
||||||
QList<int> tKeys = tokens.keys();// Take all tokens positions
|
QList<int> tKeys = tokens.keys();// Take all tokens positions
|
||||||
QList<QString> tValues = tokens.values();
|
QList<QString> tValues = tokens.values();
|
||||||
|
@ -848,10 +848,9 @@ QString VTranslateVars::FormulaToUser(const QString &formula, bool osSeparator)
|
||||||
QMap<int, QString> numbers;
|
QMap<int, QString> numbers;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
qmu::QmuTokenParser *cal = new qmu::QmuTokenParser(formula, false);// Eval formula
|
QScopedPointer<qmu::QmuTokenParser> cal(new qmu::QmuTokenParser(formula, false, false));// Eval formula
|
||||||
tokens = cal->GetTokens();// Tokens (variables, measurements)
|
tokens = cal->GetTokens();// Tokens (variables, measurements)
|
||||||
numbers = cal->GetNumbers();// All numbers in expression for changing decimal separator
|
numbers = cal->GetNumbers();// All numbers in expression for changing decimal separator
|
||||||
delete cal;
|
|
||||||
}
|
}
|
||||||
catch (qmu::QmuParserError &e)
|
catch (qmu::QmuParserError &e)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue
Block a user