diff options
author | Michael Brasser <michael.brasser@nokia.com> | 2012-06-22 09:23:26 +1000 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-06-22 06:54:59 +0200 |
commit | 55faad4873a9409bb1b33a10da7329d13a95aff9 (patch) | |
tree | b08f5b801079e49ddc9d6a5839eeb14a1e238a0f /src/qml/qml/qqmlcustomparser.cpp | |
parent | 033bf75d99c281d4a133fada297b7b141a0af555 (diff) |
Handle enum values of -1 correctly.
This was already handled correctly most places; now the
remaining cases (using an enum in ListModel, and assigning
an enum to an integer property) should also work correctly.
Task-number: QTBUG-21679
Change-Id: Ibff13f0b94da94b18e2e3bae4aa6ba44e0fa944b
Reviewed-by: Chris Adams <christopher.adams@nokia.com>
Diffstat (limited to 'src/qml/qml/qqmlcustomparser.cpp')
-rw-r--r-- | src/qml/qml/qqmlcustomparser.cpp | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/src/qml/qml/qqmlcustomparser.cpp b/src/qml/qml/qqmlcustomparser.cpp index f020376360..7c7a2f5611 100644 --- a/src/qml/qml/qqmlcustomparser.cpp +++ b/src/qml/qml/qqmlcustomparser.cpp @@ -279,18 +279,22 @@ void QQmlCustomParser::error(const QQmlCustomParserNode& node, const QString& de } /*! - If \a script is a simply enum expression (eg. Text.AlignLeft), - returns the integer equivalent (eg. 1). + If \a script is a simple enum expression (eg. Text.AlignLeft), + returns the integer equivalent (eg. 1), and sets \a ok to true. - Otherwise, returns -1. + Otherwise sets \a ok to false. + + A valid \a ok must be provided, or the function will assert. */ -int QQmlCustomParser::evaluateEnum(const QByteArray& script) const +int QQmlCustomParser::evaluateEnum(const QByteArray& script, bool *ok) const { + Q_ASSERT_X(ok, "QQmlCustomParser::evaluateEnum", "ok must not be a null pointer"); + *ok = false; int dot = script.indexOf('.'); if (dot == -1) return -1; - return compiler->evaluateEnum(QString::fromUtf8(script.left(dot)), script.mid(dot+1)); + return compiler->evaluateEnum(QString::fromUtf8(script.left(dot)), script.mid(dot+1), ok); } /*! |