1. #1
    Sencha - Community Support Team mystix's Avatar
    Join Date
    Mar 2007
    Location
    Singapore
    Posts
    6,236
    Vote Rating
    5
    mystix will become famous soon enough

      0  

    Default [2.1][FIXED] EditorGridPanel.destroy() does not destroy associated GridEditors

    [2.1][FIXED] EditorGridPanel.destroy() does not destroy associated GridEditors


    Destroying an EditorGridPanel's ColumnModel does not destroy any GridEditors defined in its ColumnModel, resulting in a memory leak.

    to reproduce this problem, type the following into the Firebug console in the Editor Grid Example:
    Code:
    var grid = Ext.getCmp(Ext.get('editor-grid').first().id);
    var id = grid.getColumnModel().getCellEditor(3, 0).field.id; // get the "Available" column's DateField id
    
    console.log(Ext.getCmp(id)); // verify that we've got the correct component
    
    grid.destroy(); // destroy the editorgrid
    console.log(Ext.getCmp(id)); // DateField is still registered with the ComponentMgr -- i.e. it hasn't been destroyed

    the following override resolves this (without destroying the ColumnModel, but rendering the same ColumnModel unusable for other EditorGridPanels):
    Code:
    Ext.override(Ext.grid.EditorGridPanel, {
      onDestroy: function() {
        var cols = this.getColumnModel().config;
        for(var i = 0, len = cols.length; i < len; i++){
          var c = cols[i];
          Ext.destroy(c.editor);
        }
        Ext.grid.EditorGridPanel.superclass.onDestroy.call(this);
      }
    });
    1 question remains though -- should the ColumnModel for the EditorGridPanel also be destroyed when it is destroyed?
    For a GridPanel, it makes sense not to destroy the ColumnModel since it can in theory be re-used (so the GridPanel.onDestroy() method is correct in simply purging the ColumnModel's listeners).

    For an EditorGridPanel though, though it is perfectly ok to reuse its ColumnModel in a different EditorGridPanel, there's no ColumnModel.destroy() method to mop up any lingering GridEditors should the ColumnModel be destroyed (i.e. simply nullfied).

  2. #2
    Sencha User
    Join Date
    Apr 2012
    Location
    Austin, Texas
    Posts
    2
    Vote Rating
    0
    brian.moeskau is an unknown quantity at this point

      0  

    Default


    Added in SVN, thanks. I think if someone is reusing a column model, they will just need to know to destroy their final grid before nulling the column model. I doubt that's a common issue.

  3. #3
    Ext User
    Join Date
    Nov 2007
    Posts
    24
    Vote Rating
    0
    keztrel is on a distinguished road

      0  

    Default


    I had some problems with this addition, since it was added in Ext 2.2

    I didn't had time to go into but with
    PHP Code:
    Ext.override(Ext.Editor, {
        
    beforeDestroy : function(){
            if (
    this.field) {
                
    this.field.destroy();
                
    this.field null;
            }
        }
    }); 
    it worked.

  4. #4
    Sencha - Community Support Team mystix's Avatar
    Join Date
    Mar 2007
    Location
    Singapore
    Posts
    6,236
    Vote Rating
    5
    mystix will become famous soon enough

      0  

    Default


    Quote Originally Posted by keztrel View Post
    I had some problems with this addition, since it was added in Ext 2.2

    I didn't had time to go into but with
    PHP Code:
    Ext.override(Ext.Editor, {
        
    beforeDestroy : function(){
            if (
    this.field) {
                
    this.field.destroy();
                
    this.field null;
            }
        }
    }); 
    it worked.
    what "problems" exactly?

  5. #5
    Sencha - Community Support Team Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,246
    Vote Rating
    95
    Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of

      0  

    Default


    Quote Originally Posted by mystix View Post
    what "problems" exactly?
    Problem described here.

  6. #6
    Sencha - Community Support Team mystix's Avatar
    Join Date
    Mar 2007
    Location
    Singapore
    Posts
    6,236
    Vote Rating
    5
    mystix will become famous soon enough

      0  

    Default


    Quote Originally Posted by Condor View Post
    Problem described here.
    current code in SVN is this actually:
    Code:
    Ext.override(Ext.Editor, {
        beforeDestroy : function(){
            Ext.destroy(this.field);
            this.field = null;
        }
    });
    so that issue should be taken care of nicely.