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>
This commit is contained in:
Ulf Hermann
2018-07-09 14:58:44 +02:00
parent 126030d079
commit 8eef50e576

View File

@@ -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);