From ab736c08c20feac9033a1a78a5007ece49b74ec9 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Wed, 16 Jan 2013 12:18:47 +0100 Subject: [PATCH] Properly mark accessor properties During the mark phase of the GC run, we didn't mark the getters and setters in accessor properties. This fixes a few crashes in the test suite. Change-Id: Ic58b317fe1fc5c923e8c114aee94c1981afd894f Reviewed-by: Simon Hausmann --- qmljs_objects.cpp | 13 +++++++++++-- qv4array.cpp | 16 ++++++++++++++++ qv4array.h | 10 +--------- 3 files changed, 28 insertions(+), 11 deletions(-) diff --git a/qmljs_objects.cpp b/qmljs_objects.cpp index 749e883..0cec5ea 100644 --- a/qmljs_objects.cpp +++ b/qmljs_objects.cpp @@ -178,9 +178,18 @@ void Object::getCollectables(QVector &objects) if (members) { for (PropertyTable::iterator it = members->begin(), eit = members->end(); it < eit; ++it) { - if ((*it) && (*it)->descriptor.isData()) - if (Object *o = (*it)->descriptor.value.asObject()) + if (!(*it)) + continue; + PropertyDescriptor &pd = (*it)->descriptor; + if (pd.isData()) { + if (Object *o = pd.value.asObject()) objects.append(o); + } else if (pd.isAccessor()) { + if (pd.get) + objects.append(pd.get); + if (pd.set) + objects.append(pd.set); + } } } array.getCollectables(objects); diff --git a/qv4array.cpp b/qv4array.cpp index dd34a7c..42c7ed9 100644 --- a/qv4array.cpp +++ b/qv4array.cpp @@ -651,5 +651,21 @@ bool Array::setLength(uint newLen) { return ok; } +void Array::getCollectables(QVector &objects) const { + uint i = sparse ? 0 : offset; + for (; i < (uint)values.size(); ++i) { + const PropertyDescriptor &pd = values.at(i); + if (pd.isData()) { + if (Object *o = pd.value.asObject()) + objects.append(o); + } else if (pd.isAccessor()) { + if (pd.get) + objects.append(pd.get); + if (pd.set) + objects.append(pd.set); + } + } +} + } } diff --git a/qv4array.h b/qv4array.h index c36d4a9..bdd3744 100644 --- a/qv4array.h +++ b/qv4array.h @@ -523,15 +523,7 @@ public: } } - void getCollectables(QVector &objects) const { - uint i = sparse ? 0 : offset; - for (; i < (uint)values.size(); ++i) { - const PropertyDescriptor &pd = values.at(i); - if (pd.isData()) - if (Object *o = pd.value.asObject()) - objects.append(o); - } - } + void getCollectables(QVector &objects) const; void push_front(Value v) { if (!sparse) { -- 2.7.4