Validate math formula immediately and show error message

This commit is contained in:
Jan Käberich 2025-02-24 13:10:52 +01:00
parent 0966466686
commit 269c7b9859
5 changed files with 37 additions and 10 deletions

View file

@ -408,10 +408,10 @@ void Trace::setMathFormula(const QString &newMathFormula)
scheduleMathCalculation(0, data.size());
}
bool Trace::mathFormularValid() const
QString Trace::getMathFormulaError() const
{
if(mathFormula.isEmpty()) {
return false;
return "Math formula must not be empty";
}
try {
ParserX parser(pckCOMMON | pckUNIT | pckCOMPLEX);
@ -428,15 +428,15 @@ bool Trace::mathFormularValid() const
}
}
if(!found) {
return false;
return "Unknown variable: "+varName;
}
}
} catch (const ParserError &e) {
// parser error occurred
return false;
return "Parsing failed: " + QString::fromStdString(e.GetMsg());
}
// all variables used in the expression are set as math sources
return true;
return "";
}
bool Trace::resolveMathSourceHashes()