Changeset 9392


Ignore:
Timestamp:
07/24/07 14:47:27 (5 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 edited

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  
    394394                                return (sPropertyName in pNode) ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP; 
    395395                        }, false); 
    396                 return vTw.firstChild(); 
     396                var vRes = vTw.firstChild(); 
     397                vTw = null; //memLeak 
     398                return vRes; 
    397399        } 
    398400        return null; 
     
    12911293                } 
    12921294                vEditor.setFocusFrom(vFirstNode); 
    1293         } 
     1295                delete this.fFrag; 
     1296        } 
     1297} 
     1298XEDInsertHisto.prototype.destroy = function(){ 
     1299        if(this.fFrag) xed.destroyBindings(this.fFrag); 
    12941300} 
    12951301 
     
    13291335} 
    13301336 
     1337XEDReplaceHisto.prototype.destroy = function(){ 
     1338        xed.destroyBindings(this.fOldBind.parentNode ? this.fNewBind : this.fOldBind); 
     1339} 
    13311340 
    13321341//************************************************************************************** 
     
    17161725        return vS+"]"; 
    17171726} 
     1727 
     1728xed.destroyBindings = function(pNode) { 
     1729        if(!pNode) return; 
     1730        function callDestroy(pNode){ 
     1731                try { 
     1732                        if("destroy" in pNode) pNode.destroy(); 
     1733                } catch(e){xed.debug("destroyNode failed : "+pNode.localName+"\n"+e);} 
     1734                return NodeFilter.FILTER_ACCEPT; 
     1735        } 
     1736        callDestroy(pNode); 
     1737        var vTw = pNode.ownerDocument.createTreeWalker(pNode, NodeFilter.SHOW_ELEMENT, callDestroy, false); 
     1738        while(vTw.nextNode()); 
     1739        vTw = null; //memLeak 
     1740} 
     1741 
    17181742/** Protège les -- par des -~- et plus généralement -(X)~- par -(X+)~- pour les commentaires imbriqués. */ 
    17191743xed.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ée. 
     
    11131119                                                - function undo() 
    11141120                                                - function redo() 
     1121                                                - Optionnel : function destroy() pour memLeaks. 
    11151122                        --> 
    11161123                        <method name="addHisto"> 
     
    11281135                                                        for(var i = 0; i < 20 && vH!=null; i++) vH = vH._EntryPrevHisto; 
    11291136                                                        this.fHistoCount = i; 
    1130                                                         if(vH) vH._EntryPrevHisto = null; 
     1137                                                        if(vH) { 
     1138                                                                var vH2 = vH._EntryPrevHisto; 
     1139                                                                delete vH._EntryPrevHisto; 
     1140                                                                if(vH2) delete vH2._EntryNextHisto; 
     1141                                                                this.xDestroyHisto(vH2); 
     1142                                                        } 
    11311143                                                } 
    11321144                                        } else { 
     
    11341146                                        } 
    11351147                                        this.fHistoPrev = pObjHisto; 
    1136                                         this.fHistoNext = null; 
     1148                                        if(this.fHistoNext) { 
     1149                                                this.xDestroyHisto(this.fHistoNext); 
     1150                                                this.fHistoNext = null; 
     1151                                        } 
    11371152                                        if(pNewEntry) { 
    11381153                                                var vEvent = document.createEvent("Events"); 
     
    12131228                                ]]></body> 
    12141229                        </method> 
    1215                         <!-- champs internes --> 
     1230                        <!-- champs et methodes internes --> 
     1231                        <method name="destroyAllHisto"> 
     1232                                <body><![CDATA[ 
     1233                                        this.xDestroyHisto(this.fHistoPrev); 
     1234                                        this.xDestroyHisto(this.fHistoNext); 
     1235                                ]]></body> 
     1236                        </method> 
     1237                        <method name="xDestroyHisto"> 
     1238                                <parameter name="pObjHisto"/> 
     1239                                <body><![CDATA[ 
     1240                                        var vH = pObjHisto; 
     1241                                        while(vH) { 
     1242                                                if("destroy" in vH) try {vH.destroy();}catch(e){xed.debug("detroy histo point failed : "+e)} 
     1243                                                vH = vH._PrevHisto || vH._EntryPrevHisto; 
     1244                                        } 
     1245                                        vH = pObjHisto._NextHisto || pObjHisto._EntryNextHisto; 
     1246                                        while(vH) { 
     1247                                                if("destroy" in vH) try {vH.destroy();}catch(e){xed.debug("detroy histo point failed : "+e)} 
     1248                                                vH = vH._NextHisto || vH._EntryNextHisto; 
     1249                                        } 
     1250                                ]]></body> 
     1251                        </method> 
    12161252                        <field name="fHistoPrev"/> 
    12171253                        <field name="fHistoNext"/> 
  • trunk/Xul_XedLib/chrome/content/scenarixedlib/core/xedUi.xbl.xml

    r9383 r9392  
    666666                                } 
    667667                        ]]></constructor> 
    668                         <destructor> 
    669                                 //memoryleaks 
     668                        <destructor>this.destroy();</destructor> 
     669                        <method name="destroy"> 
     670                                <body> 
     671                                //memLeaks 
    670672                                this.fTimerFocus.cancel(); 
    671673                                this.fTimerFocus = null; 
     
    673675                                this.fTabTw = null; 
    674676                                this.fLineTw = null; 
    675                         </destructor> 
     677                                </body> 
     678                        </method> 
    676679                        <field name="fIsRootEditor">true</field> 
    677680                        <field name="fEditor"/> 
     
    948951                        else this.parentNode.fVerticalScrollbar = this; 
    949952                  ]]></constructor> 
    950                   <destructor><![CDATA[ 
    951                         if (this.orient == 'horizontal') this.parentNode.fHorizontalScrollbar = null; 
    952                         else this.parentNode.fVerticalScrollbar = null; 
    953                   ]]></destructor> 
     953                   
     954                        <destructor>this.destroy();</destructor> 
     955                        <method name="destroy"> 
     956                                <body><![CDATA[ 
     957                                if (this.orient == 'horizontal') this.parentNode.fHorizontalScrollbar = null; 
     958                                else this.parentNode.fVerticalScrollbar = null; 
     959                          ]]></body> 
     960                  </method> 
    954961                </implementation> 
    955962        </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érialisation 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écé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>                                 
     
    274281                        <!-- API nsIControllers de l'editor. --> 
    275282                        <field name="fControllers"/> 
     283                        <!-- API nsICommandManager de l'editor (obligé de le mémorise sinon impossible de le récupére si node décroché du doc). --> 
     284                        <field name="fCommandManager"/> 
    276285                        <!-- Champ affecté par le RichTextInput pour retrouver l'input propriétaire de cette Zone. --> 
    277286                        <field name="fRichTextInput"/> 
    278287                        <!-- Noeud Editor (construit dynamiquement). --> 
    279288                        <field name="fEditorNode">document.getAnonymousElementByAttribute(this, "type", "content-primary")</field> 
    280                         <destructor><![CDATA[ 
    281                                 this.resetEditor(true); 
    282                         ]]></destructor> 
    283289                        <!-- Permet de redéfinir sa hauteur par rapport au contenu (appelé par le RichTextInput propriétaire) --> 
    284290                        <method name="autoSize"> 
     
    314320                                                //La commande cmd_bold est utilisée comme proxy pour toute modification potentielle de style lié au caret ou à la sélection. 
    315321                                                //cette commande est déclenchée par Mozilla en asynchrone lorsque le caret s'est stabilisé. 
    316                                                 this.fEditorNode.commandManager.removeCommandObserver(this.fObserver, "cmd_bold"); 
     322                                                this.fCommandManager.removeCommandObserver(this.fObserver, "cmd_bold"); 
    317323                                                delete this.fObserver.fXbl; //memLeak 
    318324                                                delete this.fObserver; //memLeak 
     
    336342                                try{ 
    337343                                        var vDoc = this.fEditorNode.contentDocument; 
     344                                        this.fCommandManager = this.fEditorNode.commandManager; 
    338345                                        // On remplit le document de l'éditeur 
    339346                                        this.fHtmlRoot = vDoc.body; 
     
    409416                                                                //La commande cmd_bold est utilisée comme proxy pour toute modification potentielle de style lié au caret ou à la sélection. 
    410417                                                                //cette commande est déclenchée par Mozilla en asynchrone lorsque le caret s'est stabilisé. 
    411                                                                 vXbl.fEditorNode.commandManager.addCommandObserver(vXbl.fObserver, "cmd_bold"); 
     418                                                                vXbl.fCommandManager.addCommandObserver(vXbl.fObserver, "cmd_bold"); 
    412419                                                        } 
    413420                 
     
    434441                                                finally { 
    435442                                                        //Init ok on se désabonne. 
    436                                                         vXbl.fEditorNode.commandManager.removeCommandObserver(this, "obs_documentCreated"); 
     443                                                        vXbl.fCommandManager.removeCommandObserver(this, "obs_documentCreated"); 
    437444                                                } 
    438445                                                 
    439446                                        } 
    440447 
    441                                         this.fEditorNode.commandManager.addCommandObserver(vObserveCreateEditor, "obs_documentCreated"); 
     448                                        this.fCommandManager.addCommandObserver(vObserveCreateEditor, "obs_documentCreated"); 
    442449                                        this.fEditorNode.makeEditable(vMethodEditor, false); 
    443450                                 
Note: See TracChangeset for help on using the changeset viewer.