Changeset 9392

Show
Ignore:
Timestamp:
24.07.2007 14:47:27 (3 years ago)
Author:
sys
Message:

memLeaks : ajout de la méthode destroy() pour compenser l'absence d'appel des destructor des XBL si les éléments ont été extraits du Document.

Location:
trunk
Files:
10 modified

Legend:

Unmodified
Added
Removed
  • trunk/Xul_Cms/chrome/content/scenaricms/widgets/item/item.xbl.xml

    r9158 r9392  
    103103                                this.xUpdateVal(); 
    104104                        ]]></constructor> 
    105                         <destructor> 
     105                        <destructor>this.destroy();</destructor> 
     106                        <method name="destroy"> 
     107                                <body> 
    106108                                if(this.fLastUri) this.fUriObject.removeUpdateListener(this, this.fLastUri); 
    107                         </destructor> 
     109                                </body> 
     110                        </method> 
    108111                        <property name="cd" onget="return this.fCd"/> 
    109112                        <property name="sp" onget="return (this.fSp || ! this.fUriObject) ? this.fSp : ut.getSpaceFromUri(this.fUriObject.getUri());"/> 
  • trunk/Xul_Cms/chrome/content/scenaricms/xed/libUiCms/providers/wspInputHistoryProvider.xbl.xml

    r5707 r9392  
    4343                <implementation implements="nsIAutoCompleteSearch"> 
    4444                        <constructor>this.fId = this.fACSearchProxy.registerProvider(this.QueryInterface(Components.interfaces.nsIAutoCompleteSearch));</constructor> 
    45                         <destructor>this.fACSearchProxy.unregisterProvider(this.fId); </destructor> 
     45                        <destructor>this.destroy();</destructor> 
     46                        <method name="destroy"> 
     47                                <body>this.fACSearchProxy.unregisterProvider(this.fId);</body> 
     48                        </method> 
    4649                        <field name="fACSearchProxy">Components.classes["@mozilla.org/autocomplete/search;1?name=scProxy"].getService(Components.interfaces.scIAutoCompleteSearchProxy);</field> 
    4750                        <field name="fId"/> 
  • trunk/Xul_Cms/chrome/content/scenaricms/xed/libUiCms/widgets/xedUiCms.xbl.xml

    r8970 r9392  
    8989                        }catch(e){xed.debug("ptritem failed:"+e);} 
    9090                        </constructor> 
     91                        <method name="destroy"> 
     92                                <body> 
     93                                        this.fItemEdit.destroy(); 
     94                                </body> 
     95                        </method> 
    9196                        <method name="onxedload"> 
    9297                        <body><![CDATA[ 
  • trunk/Xul_XedLib/chrome/content/scenarixedlib/core/xed.js

    r9384 r9392  
    393393                                return (sPropertyName in pNode) ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP; 
    394394                        }, false); 
    395                 return vTw.firstChild(); 
     395                var vRes = vTw.firstChild(); 
     396                vTw = null; //memLeak 
     397                return vRes; 
    396398        } 
    397399        return null; 
     
    12901292                } 
    12911293                vEditor.setFocusFrom(vFirstNode); 
    1292         } 
     1294                delete this.fFrag; 
     1295        } 
     1296} 
     1297XEDInsertHisto.prototype.destroy = function(){ 
     1298        if(this.fFrag) xed.destroyBindings(this.fFrag); 
    12931299} 
    12941300 
     
    13281334} 
    13291335 
     1336XEDReplaceHisto.prototype.destroy = function(){ 
     1337        xed.destroyBindings(this.fOldBind.parentNode ? this.fNewBind : this.fOldBind); 
     1338} 
    13301339 
    13311340//************************************************************************************** 
     
    17131722        return vS+"]"; 
    17141723} 
     1724 
     1725xed.destroyBindings = function(pNode) { 
     1726        if(!pNode) return; 
     1727        function callDestroy(pNode){ 
     1728                try { 
     1729                        if("destroy" in pNode) pNode.destroy(); 
     1730                } catch(e){xed.debug("destroyNode failed : "+pNode.localName+"\n"+e);} 
     1731                return NodeFilter.FILTER_ACCEPT; 
     1732        } 
     1733        callDestroy(pNode); 
     1734        var vTw = pNode.ownerDocument.createTreeWalker(pNode, NodeFilter.SHOW_ELEMENT, callDestroy, false); 
     1735        while(vTw.nextNode()); 
     1736        vTw = null; //memLeak 
     1737} 
     1738 
    17151739/** Prot� les -- par des -~- et plus g�ralement -(X)~- par -(X+)~- pour les commentaires imbriqu� */ 
    17161740xed.escapeComment = function(pText){ 
  • trunk/Xul_XedLib/chrome/content/scenarixedlib/core/xedDyn.xbl.xml

    r9199 r9392  
    4343                <implementation> 
    4444                        <field name="fEditor">this</field> 
     45                        <destructor> 
     46                                this.destroyAllHisto(); 
     47                        </destructor> 
    4548                        <method name="initEditorDyn"> 
    4649                                <parameter name="pUrlEditor"/> 
     
    199202                                                vEvent.initEvent(XEDDataChangeEvent, true, false); 
    200203                                                this.fParent.dispatchEvent(vEvent); 
     204                                        } 
     205                                        vHisto.destroy = function(){ 
     206                                                xed.destroyBindings(this.fRemovedNode); 
    201207                                        } 
    202208                                        //Note : il faut dabord ajouter l'histo avant de lancer les events, pour pouvoir ajouter des histo sur cette entr� 
     
    11111117                                                - function undo() 
    11121118                                                - function redo() 
     1119                                                - Optionnel : function destroy() pour memLeaks. 
    11131120                        --> 
    11141121                        <method name="addHisto"> 
     
    11261133                                                        for(var i = 0; i < 20 && vH!=null; i++) vH = vH._EntryPrevHisto; 
    11271134                                                        this.fHistoCount = i; 
    1128                                                         if(vH) vH._EntryPrevHisto = null; 
     1135                                                        if(vH) { 
     1136                                                                var vH2 = vH._EntryPrevHisto; 
     1137                                                                delete vH._EntryPrevHisto; 
     1138                                                                if(vH2) delete vH2._EntryNextHisto; 
     1139                                                                this.xDestroyHisto(vH2); 
     1140                                                        } 
    11291141                                                } 
    11301142                                        } else { 
     
    11321144                                        } 
    11331145                                        this.fHistoPrev = pObjHisto; 
    1134                                         this.fHistoNext = null; 
     1146                                        if(this.fHistoNext) { 
     1147                                                this.xDestroyHisto(this.fHistoNext); 
     1148                                                this.fHistoNext = null; 
     1149                                        } 
    11351150                                        if(pNewEntry) { 
    11361151                                                var vEvent = document.createEvent("Events"); 
     
    12111226                                ]]></body> 
    12121227                        </method> 
    1213                         <!-- champs internes --> 
     1228                        <!-- champs et methodes internes --> 
     1229                        <method name="destroyAllHisto"> 
     1230                                <body><![CDATA[ 
     1231                                        this.xDestroyHisto(this.fHistoPrev); 
     1232                                        this.xDestroyHisto(this.fHistoNext); 
     1233                                ]]></body> 
     1234                        </method> 
     1235                        <method name="xDestroyHisto"> 
     1236                                <parameter name="pObjHisto"/> 
     1237                                <body><![CDATA[ 
     1238                                        var vH = pObjHisto; 
     1239                                        while(vH) { 
     1240                                                if("destroy" in vH) try {vH.destroy();}catch(e){xed.debug("detroy histo point failed : "+e)} 
     1241                                                vH = vH._PrevHisto || vH._EntryPrevHisto; 
     1242                                        } 
     1243                                        vH = pObjHisto._NextHisto || pObjHisto._EntryNextHisto; 
     1244                                        while(vH) { 
     1245                                                if("destroy" in vH) try {vH.destroy();}catch(e){xed.debug("detroy histo point failed : "+e)} 
     1246                                                vH = vH._NextHisto || vH._EntryNextHisto; 
     1247                                        } 
     1248                                ]]></body> 
     1249                        </method> 
    12141250                        <field name="fHistoPrev"/> 
    12151251                        <field name="fHistoNext"/> 
  • trunk/Xul_XedLib/chrome/content/scenarixedlib/core/xedUi.xbl.xml

    r9383 r9392  
    664664                                } 
    665665                        ]]></constructor> 
    666                         <destructor> 
    667                                 //memoryleaks 
     666                        <destructor>this.destroy();</destructor> 
     667                        <method name="destroy"> 
     668                                <body> 
     669                                //memLeaks 
    668670                                this.fTimerFocus.cancel(); 
    669671                                this.fTimerFocus = null; 
     
    671673                                this.fTabTw = null; 
    672674                                this.fLineTw = null; 
    673                         </destructor> 
     675                                </body> 
     676                        </method> 
    674677                        <field name="fIsRootEditor">true</field> 
    675678                        <field name="fEditor"/> 
     
    946949                        else this.parentNode.fVerticalScrollbar = this; 
    947950                  ]]></constructor> 
    948                   <destructor><![CDATA[ 
    949                         if (this.orient == 'horizontal') this.parentNode.fHorizontalScrollbar = null; 
    950                         else this.parentNode.fVerticalScrollbar = null; 
    951                   ]]></destructor> 
     951                   
     952                        <destructor>this.destroy();</destructor> 
     953                        <method name="destroy"> 
     954                                <body><![CDATA[ 
     955                                if (this.orient == 'horizontal') this.parentNode.fHorizontalScrollbar = null; 
     956                                else this.parentNode.fVerticalScrollbar = null; 
     957                          ]]></body> 
     958                  </method> 
    952959                </implementation> 
    953960        </binding> 
  • trunk/Xul_XedLib/chrome/content/scenarixedlib/libUiBase/providers/fixedProvider.xbl.xml

    r5676 r9392  
    4545                                this.fId = this.fACSearchProxy.registerProvider(this.QueryInterface(Components.interfaces.nsIAutoCompleteSearch));  
    4646                        </constructor> 
    47                         <destructor>this.fACSearchProxy.unregisterProvider(this.fId); </destructor> 
     47                        <destructor>this.destroy();</destructor> 
     48                        <method name="destroy"> 
     49                                <body>this.fACSearchProxy.unregisterProvider(this.fId);</body> 
     50                        </method> 
    4851                        <field name="fACSearchProxy">Components.classes["@mozilla.org/autocomplete/search;1?name=scProxy"].getService(Components.interfaces.scIAutoCompleteSearchProxy);</field> 
    4952                        <field name="fId"/> 
  • trunk/Xul_XedLib/chrome/content/scenarixedlib/libUiBase/widgets/xedUiHelp.xbl.xml

    r8595 r9392  
    5959                                vEditor.fContent.addFocusStabilizedListener(this); 
    6060                        </constructor> 
    61                         <destructor> 
     61                        <destructor>this.destroy();</destructor> 
     62                        <method name="destroy"> 
     63                                <body> 
    6264                                var vEditor = xed.getEditor(this); 
    6365                                vEditor.fContent.removeFocusStabilizedListener(this); 
    64                         </destructor> 
     66                                </body> 
     67                        </method> 
    6568                        <method name="focusStabilized"> 
    6669                                <parameter name="pNode"/> 
  • trunk/Xul_XedLib/chrome/content/scenarixedlib/libUiBase/widgets/xedUiInputs.xbl.xml

    r9384 r9392  
    318318                </content> 
    319319                <implementation> 
    320                         <field name="fInputField">document.getAnonymousElementByAttribute(this, "anonid", "input")</field> 
    321320                        <property name="filtercr" onget="return this.getAttribute('filtercr')!='false'" onset="this.setAttribute('filtercr', val); return val;"/> 
    322321                        <property name="filterspaces" onget="return this.getAttribute('filterspaces')!='false'" onset="this.setAttribute('filterspaces', val); return val;"/> 
     
    324323                        <property name="filterSpecialCars" onget="return this.getAttribute('filterSpecialCars')!='false'" onset="this.setAttribute('filterSpecialCars', val); return val;"/> 
    325324                        <constructor> 
     325                                if(this.fInputField) this.destroy(); //Nouvel appel constructor, gestion memLeaks 
     326                                this.fInputField = document.getAnonymousElementByAttribute(this, "anonid", "input"); 
    326327                                //Surcharge de la property value pour court-circuiter la s�alisation et la suppression des espaces inseccables. 
    327328                                this.fInputField.__defineGetter__("value", this.__valueGetter); 
     
    330331                                this.fInputField.controllers.insertControllerAt(0, this.fXEDInputController); 
    331332                        </constructor> 
    332                         <destructor> 
    333                         try{ 
    334                                 this.fXEDInputController.destroy(); 
    335                                 this.fXEDInputController = null; 
    336                                 this.fInputField.controllers.removeControllerAt(0); 
    337                         }catch(e){xed.debug("destructor:::::::"+e);} 
    338                         </destructor> 
     333                        <destructor>this.destroy();</destructor> 
     334                        <method name="destroy"> 
     335                                <body> 
     336                                        this.fXEDInputController.destroy(); 
     337                                        this.fXEDInputController = null; 
     338                                        this.fInputField.controllers.removeControllerAt(0); 
     339                                </body> 
     340                        </method> 
    339341                        <method name="__valueGetter"> 
    340342                                <body> 
  • trunk/Xul_XedLib/chrome/content/scenarixedlib/libUiBase/widgets/xedUiRichTextInput.xbl.xml

    r9384 r9392  
    5959                <implementation> 
    6060                        <constructor> 
     61                                if(this.fRichTextZone) this.fRichTextZone.resetEditor(); //Nouvel appel constructor : gestion memLeak instance pr�dente. 
     62                                this.fRichTextZone = document.getAnonymousElementByAttribute(this, "anonid", "richText"); 
    6163                                this.fRichTextZone.fRichTextInput = this; 
    6264                        </constructor> 
    63                         <field name="fRichTextZone">document.getAnonymousElementByAttribute(this, "anonid", "richText")</field> 
     65                        <destructor>this.destroy();</destructor> 
     66                        <method name="destroy"> 
     67                                <body> 
     68                                this.fRichTextZone.resetEditor(); 
     69                                </body> 
     70                        </method> 
    6471                        <property name="realvalue"> 
    6572                                <getter>                                 
     
    273280                        <!-- API nsIControllers de l'editor. --> 
    274281                        <field name="fControllers"/> 
     282                        <!-- API nsICommandManager de l'editor (oblig�e le m�rise sinon impossible de le r�p� si node d�och�u doc). --> 
     283                        <field name="fCommandManager"/> 
    275284                        <!-- Champ affect�ar le RichTextInput pour retrouver l'input propri�ire de cette Zone. --> 
    276285                        <field name="fRichTextInput"/> 
    277286                        <!-- Noeud Editor (construit dynamiquement). --> 
    278287                        <field name="fEditorNode">document.getAnonymousElementByAttribute(this, "type", "content-primary")</field> 
    279                         <destructor><![CDATA[ 
    280                                 this.resetEditor(true); 
    281                         ]]></destructor> 
    282288                        <!-- Permet de red�nir sa hauteur par rapport au contenu (appel�ar le RichTextInput propri�ire) --> 
    283289                        <method name="autoSize"> 
     
    313319                                                //La commande cmd_bold est utilis�comme proxy pour toute modification potentielle de style li�u caret ou �a s�ction. 
    314320                                                //cette commande est d�ench�par Mozilla en asynchrone lorsque le caret s'est stabilis� 
    315                                                 this.fEditorNode.commandManager.removeCommandObserver(this.fObserver, "cmd_bold"); 
     321                                                this.fCommandManager.removeCommandObserver(this.fObserver, "cmd_bold"); 
    316322                                                delete this.fObserver.fXbl; //memLeak 
    317323                                                delete this.fObserver; //memLeak 
     
    335341                                try{ 
    336342                                        var vDoc = this.fEditorNode.contentDocument; 
     343                                        this.fCommandManager = this.fEditorNode.commandManager; 
    337344                                        // On remplit le document de l'�teur 
    338345                                        this.fHtmlRoot = vDoc.body; 
     
    408415                                                                //La commande cmd_bold est utilis�comme proxy pour toute modification potentielle de style li�u caret ou �a s�ction. 
    409416                                                                //cette commande est d�ench�par Mozilla en asynchrone lorsque le caret s'est stabilis� 
    410                                                                 vXbl.fEditorNode.commandManager.addCommandObserver(vXbl.fObserver, "cmd_bold"); 
     417                                                                vXbl.fCommandManager.addCommandObserver(vXbl.fObserver, "cmd_bold"); 
    411418                                                        } 
    412419                 
     
    433440                                                finally { 
    434441                                                        //Init ok on se d�bonne. 
    435                                                         vXbl.fEditorNode.commandManager.removeCommandObserver(this, "obs_documentCreated"); 
     442                                                        vXbl.fCommandManager.removeCommandObserver(this, "obs_documentCreated"); 
    436443                                                } 
    437444                                                 
    438445                                        } 
    439446 
    440                                         this.fEditorNode.commandManager.addCommandObserver(vObserveCreateEditor, "obs_documentCreated"); 
     447                                        this.fCommandManager.addCommandObserver(vObserveCreateEditor, "obs_documentCreated"); 
    441448                                        this.fEditorNode.makeEditable(vMethodEditor, false); 
    442449