summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAaron Kennedy <aaron.kennedy@nokia.com>2009-09-02 03:34:07 (GMT)
committerAaron Kennedy <aaron.kennedy@nokia.com>2009-09-02 03:34:07 (GMT)
commit9e7bd55bde0d614719c67977507b270dc7326f05 (patch)
treede830538b63bd59866ba69c7ce3ce1c7412c8c91
parent74774eb9e7f5b232fdafd067f19b765ede87146f (diff)
downloadQt-9e7bd55bde0d614719c67977507b270dc7326f05.zip
Qt-9e7bd55bde0d614719c67977507b270dc7326f05.tar.gz
Qt-9e7bd55bde0d614719c67977507b270dc7326f05.tar.bz2
Save object creation line and column number
This info is used by the debugger interface, and by the qmlInfo() stream.
-rw-r--r--src/declarative/qml/qmldeclarativedata_p.h5
-rw-r--r--src/declarative/qml/qmlenginedebug.cpp11
-rw-r--r--src/declarative/qml/qmlinfo.cpp16
-rw-r--r--src/declarative/qml/qmlinstruction_p.h1
-rw-r--r--src/declarative/qml/qmlvme.cpp5
5 files changed, 35 insertions, 3 deletions
diff --git a/src/declarative/qml/qmldeclarativedata_p.h b/src/declarative/qml/qmldeclarativedata_p.h
index 5a51eb7..a316c0c 100644
--- a/src/declarative/qml/qmldeclarativedata_p.h
+++ b/src/declarative/qml/qmldeclarativedata_p.h
@@ -59,6 +59,7 @@ QT_BEGIN_NAMESPACE
class QmlCompiledData;
class QmlAbstractBinding;
+class QmlContext;
class QmlDeclarativeData : public QDeclarativeData
{
public:
@@ -69,6 +70,10 @@ public:
QmlContext *context;
QmlAbstractBinding *bindings;
+ QmlContext *outerContext; // Can't this be found from context?
+ ushort lineNumber;
+ ushort columnNumber;
+
QmlCompiledData *deferredComponent; // Can't this be found from the context?
unsigned int deferredIdx;
diff --git a/src/declarative/qml/qmlenginedebug.cpp b/src/declarative/qml/qmlenginedebug.cpp
index 0e78cad..321fe74 100644
--- a/src/declarative/qml/qmlenginedebug.cpp
+++ b/src/declarative/qml/qmlenginedebug.cpp
@@ -181,9 +181,16 @@ void QmlEngineDebugServer::buildObjectList(QDataStream &message,
QmlEngineDebugServer::QmlObjectData
QmlEngineDebugServer::objectData(QObject *object)
{
+ QmlDeclarativeData *ddata = QmlDeclarativeData::get(object);
QmlObjectData rv;
- rv.lineNumber = -1;
- rv.columnNumber = -1;
+ if (ddata) {
+ rv.url = ddata->outerContext->baseUrl();
+ rv.lineNumber = ddata->lineNumber;
+ rv.columnNumber = ddata->columnNumber;
+ } else {
+ rv.lineNumber = -1;
+ rv.columnNumber = -1;
+ }
rv.objectName = object->objectName();
rv.objectType = object->metaObject()->className();
diff --git a/src/declarative/qml/qmlinfo.cpp b/src/declarative/qml/qmlinfo.cpp
index 65a4298..e47b4ab 100644
--- a/src/declarative/qml/qmlinfo.cpp
+++ b/src/declarative/qml/qmlinfo.cpp
@@ -40,6 +40,8 @@
****************************************************************************/
#include "qmlinfo.h"
+#include <private/qmldeclarativedata_p.h>
+#include <QtDeclarative/qmlcontext.h>
QT_BEGIN_NAMESPACE
@@ -80,7 +82,19 @@ QmlInfo::QmlInfo(QObject *object)
*this << "QML";
if (object)
*this << object->metaObject()->className();
- *this << "(unknown location):";
+ QmlDeclarativeData *ddata = QmlDeclarativeData::get(object);
+ if (ddata) {
+ QString location = QLatin1String("(");
+ location += ddata->outerContext->baseUrl().toString();
+ location += QLatin1String(":");
+ location += QString::number(ddata->lineNumber);
+ location += QLatin1String(":");
+ location += QString::number(ddata->columnNumber);
+ location += QLatin1String(")");
+ *this << location.toLatin1().constData();
+ } else {
+ *this << "(unknown location):";
+ }
}
/*!
diff --git a/src/declarative/qml/qmlinstruction_p.h b/src/declarative/qml/qmlinstruction_p.h
index 8861609a..ede06a2 100644
--- a/src/declarative/qml/qmlinstruction_p.h
+++ b/src/declarative/qml/qmlinstruction_p.h
@@ -170,6 +170,7 @@ public:
struct {
int type;
int data;
+ ushort column;
} create;
struct {
int data;
diff --git a/src/declarative/qml/qmlvme.cpp b/src/declarative/qml/qmlvme.cpp
index 930e6e4..7907195 100644
--- a/src/declarative/qml/qmlvme.cpp
+++ b/src/declarative/qml/qmlvme.cpp
@@ -174,6 +174,11 @@ QObject *QmlVME::run(QStack<QObject *> &stack, QmlContext *ctxt, QmlCompiledData
VME_EXCEPTION("Unable to create object of type" << types.at(instr.create.type).className);
}
+ QmlDeclarativeData *ddata = QmlDeclarativeData::get(o);
+ ddata->outerContext = ctxt;
+ ddata->lineNumber = instr.line;
+ ddata->columnNumber = instr.create.column;
+
if (instr.create.data != -1) {
QmlCustomParser *customParser =
types.at(instr.create.type).type->customParser();