From 6cd0e478860382d4ab5cf50383a464f0780893b4 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Tue, 12 Feb 2013 13:14:19 +0100 Subject: [PATCH] Saner handling of property deleting with internal classes Build up a new internal class from the empty class with the deleted member removed. The add a transition for removal from the current class to the new one. This avoids bad behavior in pathological cases where someone would remove a member, then add it again etc. Change-Id: I9f2138785780bc3b9f529056e27abe51c1055bbe Reviewed-by: Simon Hausmann --- src/v4/qv4internalclass.cpp | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/v4/qv4internalclass.cpp b/src/v4/qv4internalclass.cpp index d062e8d..b192459 100644 --- a/src/v4/qv4internalclass.cpp +++ b/src/v4/qv4internalclass.cpp @@ -99,17 +99,14 @@ void InternalClass::removeMember(Object *object, uint id) } // create a new class and add it to the tree - InternalClass *newClass = new InternalClass(*this); - newClass->propertyTable.remove(id); - newClass->nameMap.remove(propIdx); - --newClass->size; - for (QHash::iterator it = newClass->propertyTable.begin(); it != newClass->propertyTable.end(); ++it) { - if ((*it) > propIdx) - --(*it); + object->internalClass = engine->emptyClass; + for (int i = 0; i < nameMap.size(); ++i) { + if (i == propIdx) + continue; + object->internalClass->getOrAddMember(object, nameMap.at(i)); } - transitions.insert(toRemove, newClass); - object->internalClass = newClass; + transitions.insert(toRemove, object->internalClass); } uint InternalClass::find(String *string) -- 2.7.4