aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2018-07-09 14:58:44 +0200
committerUlf Hermann <ulf.hermann@qt.io>2018-07-09 13:44:36 +0000
commit8eef50e576daf95e21a8fe0dd5f5bf68e3b354b3 (patch)
treea830324b54e13e222e4f48b6f6e7315d9d07dab4
parent126030d079b7309a9487cd4138e40da49e617341 (diff)
Qml Debugger: Disallow editing of items with children
The debugger will treat any value you put in there as string, and then fail to update the item because it doesn't expect the type to change. Proper editing of JavaScript objects requires quite a bit more UI than this, so disallow it for now. Task-number: QTCREATORBUG-20736 Change-Id: I7bf6e7a3747cde3c6682b66aaa810291f753e85d Reviewed-by: hjk <hjk@qt.io>
-rw-r--r--src/plugins/debugger/qml/qmlengine.cpp18
1 files changed, 12 insertions, 6 deletions
diff --git a/src/plugins/debugger/qml/qmlengine.cpp b/src/plugins/debugger/qml/qmlengine.cpp
index 9f5a30315f..2e0f655abd 100644
--- a/src/plugins/debugger/qml/qmlengine.cpp
+++ b/src/plugins/debugger/qml/qmlengine.cpp
@@ -138,6 +138,12 @@ struct LookupData
typedef QHash<int, LookupData> LookupItems; // id -> (iname, exp)
+static void setWatchItemHasChildren(WatchItem *item, bool hasChildren)
+{
+ item->setHasChildren(hasChildren);
+ item->valueEditable = !hasChildren;
+}
+
class QmlEnginePrivate : public QmlDebugClient
{
public:
@@ -1311,7 +1317,7 @@ void QmlEnginePrivate::handleEvaluateExpression(const QVariantMap &response,
if (success) {
item->type = body.type;
item->value = body.value.toString();
- item->setHasChildren(body.hasChildren());
+ setWatchItemHasChildren(item, body.hasChildren());
} else {
//Do not set type since it is unknown
item->setError(body.value.toString());
@@ -2156,11 +2162,11 @@ void QmlEnginePrivate::handleFrame(const QVariantMap &response)
item->id = objectData.handle;
item->type = objectData.type;
item->value = objectData.value.toString();
- item->setHasChildren(objectData.hasChildren());
+ setWatchItemHasChildren(item, objectData.hasChildren());
// In case of global object, we do not get children
// Set children nevertheless and query later.
if (item->value == "global") {
- item->setHasChildren(true);
+ setWatchItemHasChildren(item, true);
item->id = 0;
}
watchHandler->insertItem(item);
@@ -2244,7 +2250,7 @@ void QmlEnginePrivate::handleScope(const QVariantMap &response)
item->id = localData.handle;
item->type = localData.type;
item->value = localData.value.toString();
- item->setHasChildren(localData.hasChildren());
+ setWatchItemHasChildren(item.get(), localData.hasChildren());
if (localData.value.isValid() || item->wantsChildren || localData.expectedProperties == 0) {
WatchHandler *watchHander = engine->watchHandler();
@@ -2390,7 +2396,7 @@ void QmlEnginePrivate::insertSubItems(WatchItem *parent, const QVariantList &pro
item->value = propertyData.value.toString();
if (item->type.isEmpty() || expandedINames.contains(item->iname))
itemsToLookup.insert(propertyData.handle, {item->iname, item->name, item->exp});
- item->setHasChildren(propertyData.hasChildren());
+ setWatchItemHasChildren(item.get(), propertyData.hasChildren());
parent->appendChild(item.release());
}
@@ -2446,7 +2452,7 @@ void QmlEnginePrivate::handleLookup(const QVariantMap &response)
item->type = bodyObjectData.type;
item->value = bodyObjectData.value.toString();
- item->setHasChildren(bodyObjectData.hasChildren());
+ setWatchItemHasChildren(item, bodyObjectData.hasChildren());
insertSubItems(item, bodyObjectData.properties);
engine->watchHandler()->insertItem(item);