summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobin Burchell <robin.burchell@viroteck.net>2016-01-04 16:16:49 +0100
committerRobin Burchell <robin.burchell@viroteck.net>2016-01-05 09:39:22 +0000
commit71f6752c62fe6198206be1d422f7fcf13b0067dc (patch)
treea10f8bdfb7906a30cd26ab84d9b9249df27a9462
parent5588eec637fc521576318753410dca62767dfa85 (diff)
QQmlXmlHttpRequest: Fix a memory leak on use of XMLHttpRequest's responseXML.
DocumentImpl (the root of all evil) inherits QQmlRefCount, thus, it has an initial refcount of 1. We correctly released the initial ref in the case of error, but if there is no error, we don't: we pass it over to v4 using class Node which (in Node::Node) increments the refcount again. When Node is later on collected by the GC, the document's refcount is never decreased past the initial ref, thus, not deleted. Task-number: QTBUG-50231 Change-Id: Icefe4391a785c95cb8900219be8ba71f9c53785f Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
-rw-r--r--src/qml/qml/qqmlxmlhttprequest.cpp1
1 files changed, 1 insertions, 0 deletions
diff --git a/src/qml/qml/qqmlxmlhttprequest.cpp b/src/qml/qml/qqmlxmlhttprequest.cpp
index 043113bc31..3521384d77 100644
--- a/src/qml/qml/qqmlxmlhttprequest.cpp
+++ b/src/qml/qml/qqmlxmlhttprequest.cpp
@@ -856,6 +856,7 @@ ReturnedValue Document::load(ExecutionEngine *v4, const QByteArray &data)
}
ScopedObject instance(scope, v4->memoryManager->allocObject<Node>(document));
+ document->release(); // the GC should own the NodeImpl via Node now
ScopedObject p(scope);
instance->setPrototype((p = Document::prototype(v4)));
return instance.asReturnedValue();