PDA

View Full Version : Ext.data.Model destroy() method is broken for several stores



MikeSidorov
17 Dec 2012, 5:26 AM
REQUIRED INFORMATION

Ext version tested:

Ext 4.1.3
Description:

In 4.1.3 the destroy() method of Ext.data.Model loops through all of the stores instance is bound to and removes the instance. This loop is done with the cycle:
for(storeCount = stores.length; i < storeCount; i++) { It calls Ext.data.Store#remove method that internally call Ext.data.Model#unjoin method of the instance, modifying its stores array. Thus after the first deleted store the cycle will try to loop to (no more) existing array items.
Steps to reproduce the problem:

Create a model instance,
Bind it to 2 or more stores,
Try to call its destroy method.
INFORMATION
Possible fix:

maybe worth changing the code inside Ext.data.Model#destroy from
for(storeCount = stores.length; i < storeCount; i++) {
store = stores[i]; to something like
while (store = me.store) {

Animal
17 Dec 2012, 5:36 AM
The way we fixed it was to do



stores = Ext.Array.clone(me.stores);


before looping through them.