forked from qt-creator/qt-creator
QmlEngine: Do not leak items
Change-Id: Ib06b4fbd44c9c0fd87ae9f719563d1533334af77 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
This commit is contained in:
@@ -72,6 +72,8 @@
|
|||||||
#include <QPlainTextEdit>
|
#include <QPlainTextEdit>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
|
|
||||||
|
#include <memory.h>
|
||||||
|
|
||||||
#define DEBUG_QML 0
|
#define DEBUG_QML 0
|
||||||
#if DEBUG_QML
|
#if DEBUG_QML
|
||||||
# define SDEBUG(s) qDebug() << s
|
# define SDEBUG(s) qDebug() << s
|
||||||
@@ -2250,7 +2252,7 @@ void QmlEnginePrivate::handleScope(const QVariantMap &response)
|
|||||||
LookupItems itemsToLookup;
|
LookupItems itemsToLookup;
|
||||||
foreach (const QVariant &property, objectData.properties) {
|
foreach (const QVariant &property, objectData.properties) {
|
||||||
QmlV8ObjectData localData = extractData(property);
|
QmlV8ObjectData localData = extractData(property);
|
||||||
auto item = new WatchItem;
|
std::unique_ptr<WatchItem> item(new WatchItem);
|
||||||
item->exp = localData.name;
|
item->exp = localData.name;
|
||||||
//Check for v8 specific local data
|
//Check for v8 specific local data
|
||||||
if (item->exp.startsWith('.') || item->exp.isEmpty())
|
if (item->exp.startsWith('.') || item->exp.isEmpty())
|
||||||
@@ -2264,7 +2266,7 @@ void QmlEnginePrivate::handleScope(const QVariantMap &response)
|
|||||||
item->type = localData.type;
|
item->type = localData.type;
|
||||||
item->value = localData.value.toString();
|
item->value = localData.value.toString();
|
||||||
item->setHasChildren(localData.properties.count());
|
item->setHasChildren(localData.properties.count());
|
||||||
engine->watchHandler()->insertItem(item);
|
engine->watchHandler()->insertItem(item.release());
|
||||||
} else {
|
} else {
|
||||||
itemsToLookup.insert(int(item->id), {item->iname, item->name, item->exp});
|
itemsToLookup.insert(int(item->id), {item->iname, item->name, item->exp});
|
||||||
}
|
}
|
||||||
@@ -2383,7 +2385,7 @@ void QmlEnginePrivate::insertSubItems(WatchItem *parent, const QVariantList &pro
|
|||||||
const QSet<QString> expandedINames = engine->watchHandler()->expandedINames();
|
const QSet<QString> expandedINames = engine->watchHandler()->expandedINames();
|
||||||
foreach (const QVariant &property, properties) {
|
foreach (const QVariant &property, properties) {
|
||||||
QmlV8ObjectData propertyData = extractData(property);
|
QmlV8ObjectData propertyData = extractData(property);
|
||||||
auto item = new WatchItem;
|
std::unique_ptr<WatchItem> item(new WatchItem);
|
||||||
item->name = propertyData.name;
|
item->name = propertyData.name;
|
||||||
|
|
||||||
// Check for v8 specific local data
|
// Check for v8 specific local data
|
||||||
@@ -2405,7 +2407,7 @@ void QmlEnginePrivate::insertSubItems(WatchItem *parent, const QVariantList &pro
|
|||||||
if (item->type.isEmpty() || expandedINames.contains(item->iname))
|
if (item->type.isEmpty() || expandedINames.contains(item->iname))
|
||||||
itemsToLookup.insert(propertyData.handle, {item->iname, item->name, item->exp});
|
itemsToLookup.insert(propertyData.handle, {item->iname, item->name, item->exp});
|
||||||
item->setHasChildren(propertyData.properties.count() > 0);
|
item->setHasChildren(propertyData.properties.count() > 0);
|
||||||
parent->appendChild(item);
|
parent->appendChild(item.release());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (boolSetting(SortStructMembers)) {
|
if (boolSetting(SortStructMembers)) {
|
||||||
|
Reference in New Issue
Block a user