aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/qml/qqmlxmlhttprequest.cpp
diff options
context:
space:
mode:
authorErik Verbruggen <erik.verbruggen@digia.com>2016-09-09 10:06:31 +0200
committerErik Verbruggen <erik.verbruggen@qt.io>2016-10-05 13:15:18 +0000
commit64afa01c32fc1824b280452ceb1ade4f655487f2 (patch)
treef5775f2ddfd5145ae26df41a356dfa14172200b7 /src/qml/qml/qqmlxmlhttprequest.cpp
parenta166367bd877a55e552e3dfe5cf2ee7fa1561100 (diff)
QML: Introduce destroy() on Base subclasses
This removes the destructors of subclasses of Base, making them nearly trivial. Change-Id: Ia6f7d467e87899b5ad37b8709a8f633a51689d59 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/qml/qml/qqmlxmlhttprequest.cpp')
-rw-r--r--src/qml/qml/qqmlxmlhttprequest.cpp33
1 files changed, 20 insertions, 13 deletions
diff --git a/src/qml/qml/qqmlxmlhttprequest.cpp b/src/qml/qml/qqmlxmlhttprequest.cpp
index 85e17525a5..5128fc0f08 100644
--- a/src/qml/qml/qqmlxmlhttprequest.cpp
+++ b/src/qml/qml/qqmlxmlhttprequest.cpp
@@ -175,17 +175,24 @@ namespace Heap {
struct NamedNodeMap : Object {
NamedNodeMap(NodeImpl *data, const QList<NodeImpl *> &list);
- ~NamedNodeMap() {
+ void destroy() {
+ delete listPtr;
if (d)
d->release();
}
- QList<NodeImpl *> list; // Only used in NamedNodeMap
+ QList<NodeImpl *> &list() {
+ if (listPtr == nullptr)
+ listPtr = new QList<NodeImpl *>;
+ return *listPtr;
+ }
+
+ QList<NodeImpl *> *listPtr; // Only used in NamedNodeMap
NodeImpl *d;
};
struct NodeList : Object {
NodeList(NodeImpl *data);
- ~NodeList() {
+ void destroy() {
if (d)
d->release();
}
@@ -198,7 +205,7 @@ struct NodePrototype : Object {
struct Node : Object {
Node(NodeImpl *data);
- ~Node() {
+ void destroy() {
if (d)
d->release();
}
@@ -222,9 +229,9 @@ public:
};
Heap::NamedNodeMap::NamedNodeMap(NodeImpl *data, const QList<NodeImpl *> &list)
- : list(list)
- , d(data)
+ : d(data)
{
+ this->list() = list;
if (d)
d->addref();
}
@@ -877,10 +884,10 @@ ReturnedValue NamedNodeMap::getIndexed(const Managed *m, uint index, bool *hasPr
const NamedNodeMap *r = static_cast<const NamedNodeMap *>(m);
QV4::ExecutionEngine *v4 = r->engine();
- if ((int)index < r->d()->list.count()) {
+ if ((int)index < r->d()->list().count()) {
if (hasProperty)
*hasProperty = true;
- return Node::create(v4, r->d()->list.at(index));
+ return Node::create(v4, r->d()->list().at(index));
}
if (hasProperty)
*hasProperty = false;
@@ -895,14 +902,14 @@ ReturnedValue NamedNodeMap::get(const Managed *m, String *name, bool *hasPropert
name->makeIdentifier(v4);
if (name->equals(v4->id_length()))
- return Primitive::fromInt32(r->d()->list.count()).asReturnedValue();
+ return Primitive::fromInt32(r->d()->list().count()).asReturnedValue();
QString str = name->toQString();
- for (int ii = 0; ii < r->d()->list.count(); ++ii) {
- if (r->d()->list.at(ii)->name == str) {
+ for (int ii = 0; ii < r->d()->list().count(); ++ii) {
+ if (r->d()->list().at(ii)->name == str) {
if (hasProperty)
*hasProperty = true;
- return Node::create(v4, r->d()->list.at(ii));
+ return Node::create(v4, r->d()->list().at(ii));
}
}
@@ -1588,7 +1595,7 @@ namespace Heap {
struct QQmlXMLHttpRequestWrapper : Object {
QQmlXMLHttpRequestWrapper(QQmlXMLHttpRequest *request);
- ~QQmlXMLHttpRequestWrapper() {
+ void destroy() {
delete request;
}
QQmlXMLHttpRequest *request;