QmlDebugger: adding slots to items in Live Preview
authorChristiaan Janssen <christiaan.janssen@nokia.com>
Fri, 29 Apr 2011 13:33:11 +0000 (15:33 +0200)
committerChristiaan Janssen <christiaan.janssen@nokia.com>
Fri, 27 May 2011 13:59:03 +0000 (15:59 +0200)
Reviewed-by: Kai Koehne
(cherry picked from commit 1f0f8a1b15fa4efa58feb2799614afc8bf0bd6e3)

src/declarative/qml/qdeclarativeenginedebug.cpp
src/declarative/qml/qdeclarativeenginedebug_p.h

index e878f19..330fcb9 100644 (file)
@@ -524,8 +524,13 @@ void QDeclarativeEngineDebugServer::messageReceived(const QByteArray &message)
         QString propertyName;
         QVariant expr;
         bool isLiteralValue;
+        QString filename;
+        int line;
         ds >> objectId >> propertyName >> expr >> isLiteralValue;
-        setBinding(objectId, propertyName, expr, isLiteralValue);
+        if (!ds.atEnd()) { // backward compatibility from 2.1, 2.2
+            ds >> filename >> line;
+        }
+        setBinding(objectId, propertyName, expr, isLiteralValue, filename, line);
     } else if (type == "RESET_BINDING") {
         int objectId;
         QString propertyName;
@@ -543,7 +548,9 @@ void QDeclarativeEngineDebugServer::messageReceived(const QByteArray &message)
 void QDeclarativeEngineDebugServer::setBinding(int objectId,
                                                const QString &propertyName,
                                                const QVariant &expression,
-                                               bool isLiteralValue)
+                                               bool isLiteralValue,
+                                               QString filename,
+                                               int line)
 {
     QObject *object = objectForId(objectId);
     QDeclarativeContext *context = qmlContext(object);
@@ -565,6 +572,7 @@ void QDeclarativeEngineDebugServer::setBinding(int objectId,
                             newBinding = new QDeclarativeBinding(expression.toString(), object, context);
                             newBinding->setTarget(property);
                             newBinding->setNotifyOnValueChanged(true);
+                            newBinding->setSourceLocation(filename, line);
                         }
 
                         state->changeBindingInRevertList(object, propertyName, newBinding);
@@ -580,11 +588,12 @@ void QDeclarativeEngineDebugServer::setBinding(int objectId,
                     property.write(expression);
                 } else if (hasValidSignal(object, propertyName)) {
                     QDeclarativeExpression *declarativeExpression = new QDeclarativeExpression(context, object, expression.toString());
-                    QDeclarativeExpression *oldExpression = QDeclarativePropertyPrivate::setSignalExpression(property, declarativeExpression);
-                    declarativeExpression->setSourceLocation(oldExpression->sourceFile(), oldExpression->lineNumber());
+                    QDeclarativePropertyPrivate::setSignalExpression(property, declarativeExpression);
+                    declarativeExpression->setSourceLocation(filename, line);
                 } else if (property.isProperty()) {
                     QDeclarativeBinding *binding = new QDeclarativeBinding(expression.toString(), object, context);
                     binding->setTarget(property);
+                    binding->setSourceLocation(filename, line);
                     binding->setNotifyOnValueChanged(true);
                     QDeclarativeAbstractBinding *oldBinding = QDeclarativePropertyPrivate::setBinding(property, binding);
                     if (oldBinding)
index 7e7676b..804a043 100644 (file)
@@ -115,7 +115,7 @@ private:
     QDeclarativeObjectData objectData(QObject *);
     QDeclarativeObjectProperty propertyData(QObject *, int);
     QVariant valueContents(const QVariant &defaultValue) const;
-    void setBinding(int objectId, const QString &propertyName, const QVariant &expression, bool isLiteralValue);
+    void setBinding(int objectId, const QString &propertyName, const QVariant &expression, bool isLiteralValue, QString filename = QString(), int line = -1);
     void resetBinding(int objectId, const QString &propertyName);
     void setMethodBody(int objectId, const QString &method, const QString &body);