Success! Looks like we've fixed this one. According to our records the fix was applied for EXTJS-7749 in 4.2.0.265.
  1. #1
    Ext JS Premium Member
    Join Date
    Jan 2012
    Posts
    1
    Vote Rating
    0
    erik.marcussen is on a distinguished road

      0  

    Default ExtJS 4.1.3 Ext.data.Model.destroy() breaks when model is part of more than one store

    ExtJS 4.1.3 Ext.data.Model.destroy() breaks when model is part of more than one store


    In ExtJS 4.1.3 the callback handler in the Ext.data.Model.destroy() iterates the stores and removes the record from each store. Since this is also mutating the Ext.data.Model.stores collection, the code breaks on the second iteration with doing store.remove(model, true) when the store variable is undefined.

    Code:
            callback = function(operation) {
                args = [me, operation];
                if (operation.wasSuccessful()) {
                    for(storeCount = stores.length; i < storeCount; i++) {
                        store = stores[i];
                        
                        // Remove this record from Store. Avoid Store handling anything by passing the "isMove" flag
                        // BUG: Here the stores collection is mutated
                        store.remove(me, true);
                        if (isNotPhantom) {
                            store.fireEvent('write', store, operation);
                        }
                    }
                    me.clearListeners();
                    Ext.callback(options.success, scope, args);
                } else {
                    Ext.callback(options.failure, scope, args);
                }
                Ext.callback(options.callback, scope, args);
            };
    Maybe the fix is to iterate the collection in reverse order?

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,207
    Vote Rating
    856
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    Thanks for the report! I have opened a bug in our bug tracker.

Thread Participants: 1

Tags for this Thread