From 808f17756887d2fc95d526ee4aec741cb5730fad Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Tue, 4 Mar 2014 16:34:48 +0100 Subject: [PATCH] Add some leading white space to generated code for QML signals. Like this the column numbers in the generated code are correct. We rely on the column numbers in quite a few places. The alternative solution of extending the Javascript parser to add an initial column offset would result in much more code and complexity. const-casting the column number and adding to it after compiling would be an option but as the column number may be saved in other places, too, this is not desirable. Task-number: QTBUG-37226 Change-Id: I0d11816d96ff4e7c756064646755a3e9874f9790 Reviewed-by: Simon Hausmann --- src/qml/qml/qqmlboundsignal.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/qml/qml/qqmlboundsignal.cpp b/src/qml/qml/qqmlboundsignal.cpp index f7ece53..a5e2397 100644 --- a/src/qml/qml/qqmlboundsignal.cpp +++ b/src/qml/qml/qqmlboundsignal.cpp @@ -188,7 +188,10 @@ void QQmlBoundSignalExpression::evaluate(void **a) Q_ASSERT(!m_extra.isNull()); QString expression; - expression = QStringLiteral("(function "); + // Add some leading whitespace to account for the binding's column offset. + // It's 2 off because a, we start counting at 1 and b, the '(' below is not counted. + expression.fill(QChar(QChar::Space), qMax(m_extra->m_sourceLocation.column, (quint16)2) - 2); + expression += QStringLiteral("(function "); expression += m_extra->m_handlerName; expression += QLatin1Char('('); -- 2.7.4