From: Lars Knoll Date: Tue, 12 Feb 2013 12:14:19 +0000 (+0100) Subject: Saner handling of property deleting with internal classes X-Git-Tag: upstream/5.2.1~669^2~659^2~278 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=6cd0e478860382d4ab5cf50383a464f0780893b4;p=platform%2Fupstream%2Fqtdeclarative.git 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 --- 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)