summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorBea Lam <bea.lam@nokia.com>2010-03-24 03:32:37 (GMT)
committerBea Lam <bea.lam@nokia.com>2010-03-24 03:40:28 (GMT)
commit929488ba788549a9b38c1ab3784307b575a537a5 (patch)
tree0e7d47e0fe3b4ea2fcf8b8630039fa29f9587397 /src
parent50e3f9dba978709c35c869ccaa8345719f23deb1 (diff)
downloadQt-929488ba788549a9b38c1ab3784307b575a537a5.zip
Qt-929488ba788549a9b38c1ab3784307b575a537a5.tar.gz
Qt-929488ba788549a9b38c1ab3784307b575a537a5.tar.bz2
Add object ids to the metadata provided in debugger classes.
Diffstat (limited to 'src')
-rw-r--r--src/declarative/debugger/qdeclarativedebug.cpp14
-rw-r--r--src/declarative/debugger/qdeclarativedebug_p.h2
-rw-r--r--src/declarative/qml/qdeclarativecontext.cpp15
-rw-r--r--src/declarative/qml/qdeclarativecontext_p.h2
-rw-r--r--src/declarative/qml/qdeclarativeenginedebug.cpp15
-rw-r--r--src/declarative/qml/qdeclarativeenginedebug_p.h1
-rw-r--r--src/declarative/qml/qdeclarativeintegercache.cpp10
-rw-r--r--src/declarative/qml/qdeclarativeintegercache_p.h1
8 files changed, 52 insertions, 8 deletions
diff --git a/src/declarative/debugger/qdeclarativedebug.cpp b/src/declarative/debugger/qdeclarativedebug.cpp
index e4b7d4d..677d05f 100644
--- a/src/declarative/debugger/qdeclarativedebug.cpp
+++ b/src/declarative/debugger/qdeclarativedebug.cpp
@@ -151,6 +151,7 @@ void QDeclarativeEngineDebugPrivate::decode(QDataStream &ds, QDeclarativeDebugOb
ds >> data;
o.m_debugId = data.objectId;
o.m_class = data.objectType;
+ o.m_idString = data.idString;
o.m_name = data.objectName;
o.m_source.m_url = data.url;
o.m_source.m_lineNumber = data.lineNumber;
@@ -750,8 +751,8 @@ QDeclarativeDebugObjectReference::QDeclarativeDebugObjectReference(int debugId)
}
QDeclarativeDebugObjectReference::QDeclarativeDebugObjectReference(const QDeclarativeDebugObjectReference &o)
-: m_debugId(o.m_debugId), m_class(o.m_class), m_name(o.m_name),
- m_source(o.m_source), m_contextDebugId(o.m_contextDebugId),
+: m_debugId(o.m_debugId), m_class(o.m_class), m_idString(o.m_idString),
+ m_name(o.m_name), m_source(o.m_source), m_contextDebugId(o.m_contextDebugId),
m_properties(o.m_properties), m_children(o.m_children)
{
}
@@ -759,8 +760,8 @@ QDeclarativeDebugObjectReference::QDeclarativeDebugObjectReference(const QDeclar
QDeclarativeDebugObjectReference &
QDeclarativeDebugObjectReference::operator=(const QDeclarativeDebugObjectReference &o)
{
- m_debugId = o.m_debugId; m_class = o.m_class; m_name = o.m_name;
- m_source = o.m_source; m_contextDebugId = o.m_contextDebugId;
+ m_debugId = o.m_debugId; m_class = o.m_class; m_idString = o.m_idString;
+ m_name = o.m_name; m_source = o.m_source; m_contextDebugId = o.m_contextDebugId;
m_properties = o.m_properties; m_children = o.m_children;
return *this;
}
@@ -775,6 +776,11 @@ QString QDeclarativeDebugObjectReference::className() const
return m_class;
}
+QString QDeclarativeDebugObjectReference::idString() const
+{
+ return m_idString;
+}
+
QString QDeclarativeDebugObjectReference::name() const
{
return m_name;
diff --git a/src/declarative/debugger/qdeclarativedebug_p.h b/src/declarative/debugger/qdeclarativedebug_p.h
index f0c7a77..4ead232 100644
--- a/src/declarative/debugger/qdeclarativedebug_p.h
+++ b/src/declarative/debugger/qdeclarativedebug_p.h
@@ -230,6 +230,7 @@ public:
int debugId() const;
QString className() const;
+ QString idString() const;
QString name() const;
QDeclarativeDebugFileReference source() const;
@@ -242,6 +243,7 @@ private:
friend class QDeclarativeEngineDebugPrivate;
int m_debugId;
QString m_class;
+ QString m_idString;
QString m_name;
QDeclarativeDebugFileReference m_source;
int m_contextDebugId;
diff --git a/src/declarative/qml/qdeclarativecontext.cpp b/src/declarative/qml/qdeclarativecontext.cpp
index f801a88..1236923 100644
--- a/src/declarative/qml/qdeclarativecontext.cpp
+++ b/src/declarative/qml/qdeclarativecontext.cpp
@@ -730,6 +730,21 @@ void QDeclarativeContextData::setIdPropertyData(QDeclarativeIntegerCache *data)
idValues = new ContextGuard[idValueCount];
}
+QString QDeclarativeContextData::findObjectId(const QObject *obj) const
+{
+ if (!idValues || !propertyNames)
+ return QString();
+
+ for (int i=0; i<idValueCount; i++) {
+ if (idValues[i] == obj)
+ return propertyNames->findId(i);
+ }
+
+ if (linkedContext)
+ return linkedContext->findObjectId(obj);
+ return QString();
+}
+
QDeclarativeContext *QDeclarativeContextData::asQDeclarativeContext()
{
if (!publicContext)
diff --git a/src/declarative/qml/qdeclarativecontext_p.h b/src/declarative/qml/qdeclarativecontext_p.h
index f07045e..e5f18b3 100644
--- a/src/declarative/qml/qdeclarativecontext_p.h
+++ b/src/declarative/qml/qdeclarativecontext_p.h
@@ -190,6 +190,8 @@ public:
// Linked contexts. this owns linkedContext.
QDeclarativeContextData *linkedContext;
+ QString findObjectId(const QObject *obj) const;
+
static QDeclarativeContextData *get(QDeclarativeContext *context) {
return QDeclarativeContextPrivate::get(context)->data;
}
diff --git a/src/declarative/qml/qdeclarativeenginedebug.cpp b/src/declarative/qml/qdeclarativeenginedebug.cpp
index a377b35..d30aa8e 100644
--- a/src/declarative/qml/qdeclarativeenginedebug.cpp
+++ b/src/declarative/qml/qdeclarativeenginedebug.cpp
@@ -68,16 +68,16 @@ QDeclarativeEngineDebugServer::QDeclarativeEngineDebugServer(QObject *parent)
QDataStream &operator<<(QDataStream &ds,
const QDeclarativeEngineDebugServer::QDeclarativeObjectData &data)
{
- ds << data.url << data.lineNumber << data.columnNumber << data.objectName
- << data.objectType << data.objectId << data.contextId;
+ ds << data.url << data.lineNumber << data.columnNumber << data.idString
+ << data.objectName << data.objectType << data.objectId << data.contextId;
return ds;
}
QDataStream &operator>>(QDataStream &ds,
QDeclarativeEngineDebugServer::QDeclarativeObjectData &data)
{
- ds >> data.url >> data.lineNumber >> data.columnNumber >> data.objectName
- >> data.objectType >> data.objectId >> data.contextId;
+ ds >> data.url >> data.lineNumber >> data.columnNumber >> data.idString
+ >> data.objectName >> data.objectType >> data.objectId >> data.contextId;
return ds;
}
@@ -275,6 +275,13 @@ QDeclarativeEngineDebugServer::objectData(QObject *object)
rv.columnNumber = -1;
}
+ QDeclarativeContext *context = qmlContext(object);
+ if (context) {
+ QDeclarativeContextData *cdata = QDeclarativeContextData::get(context);
+ if (cdata)
+ rv.idString = cdata->findObjectId(object);
+ }
+
rv.objectName = object->objectName();
rv.objectId = QDeclarativeDebugService::idForObject(object);
rv.contextId = QDeclarativeDebugService::idForObject(qmlContext(object));
diff --git a/src/declarative/qml/qdeclarativeenginedebug_p.h b/src/declarative/qml/qdeclarativeenginedebug_p.h
index a95449b..9491411 100644
--- a/src/declarative/qml/qdeclarativeenginedebug_p.h
+++ b/src/declarative/qml/qdeclarativeenginedebug_p.h
@@ -75,6 +75,7 @@ public:
QUrl url;
int lineNumber;
int columnNumber;
+ QString idString;
QString objectName;
QString objectType;
int objectId;
diff --git a/src/declarative/qml/qdeclarativeintegercache.cpp b/src/declarative/qml/qdeclarativeintegercache.cpp
index 8fa210f..be36471 100644
--- a/src/declarative/qml/qdeclarativeintegercache.cpp
+++ b/src/declarative/qml/qdeclarativeintegercache.cpp
@@ -64,6 +64,16 @@ void QDeclarativeIntegerCache::clear()
engine = 0;
}
+QString QDeclarativeIntegerCache::findId(int value) const
+{
+ for (StringCache::ConstIterator iter = stringCache.begin();
+ iter != stringCache.end(); ++iter) {
+ if (iter.value() && iter.value()->value == value)
+ return iter.key();
+ }
+ return QString();
+}
+
void QDeclarativeIntegerCache::add(const QString &id, int value)
{
Q_ASSERT(!stringCache.contains(id));
diff --git a/src/declarative/qml/qdeclarativeintegercache_p.h b/src/declarative/qml/qdeclarativeintegercache_p.h
index b57565e..5fb5a76 100644
--- a/src/declarative/qml/qdeclarativeintegercache_p.h
+++ b/src/declarative/qml/qdeclarativeintegercache_p.h
@@ -73,6 +73,7 @@ public:
inline int count() const;
void add(const QString &, int);
int value(const QString &);
+ QString findId(int value) const;
inline int value(const QScriptDeclarativeClass::Identifier &id) const;
protected: