Details
-
Bug
-
Resolution: Done
-
P2: Important
-
5.10.1
-
None
-
Qt 5.10.1
Windows 10 64bit
MSVC 2015 64bit
Description
QQmlExpression::hasError() always returns false even though given expression is not valid.
Also, QQmlExpression::error() is not set with invalid expression.
This makes errors in expression undetectable.
Here's example program:
#include <QtCore/QDebug> #include <QtCore/QCoreApplication> #include <QtQml/QQmlEngine> #include <QtQml/QQmlComponent> #include <QtQml/QQmlExpression> auto main(int argc, char **argv) -> int { QCoreApplication app{argc, argv}; QQmlEngine engine; QObject scope; QQmlExpression expr{engine.rootContext(), &scope, "{"}; expr.evaluate(); qDebug() << "error?" << expr.hasError(); return 0; }
I expect the output be "error? true", but here's the actual output:
<Unknown File>: SyntaxError: Expected token `}'
error? false
Although the SyntaxError is printed by Qt itself, hasError() still returns false.
Attachments
For Gerrit Dashboard: QTBUG-67240 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
224524,3 | Fix QQmlExpression::hasError()/error() on syntax errors | 5.11 | qt/qtdeclarative | Status: MERGED | +2 | 0 |