All, learning a lot in this little thread. Is there an authoritative guide / manual wrt destruction in QooxDoo and JavaScript ?
Coming from C++ I am usually very good in deleting allocated memory. In JavaScript though I am confused, to say the least. So my garbage leaves a lot to be collected :( Thanks, Varol On 11/28/2013 10:33 AM, Peter Schneider wrote: > Hi there, > > independent of any "rule of thumb" I think the proposed destructor should be > included (unless there is STRONG reasoning against it). > > This is because: > - "who says 'new' should say 'delete'"[*] and > - "who says 'addListener' should say 'removeListener'" and > - "who says 'bind' should say 'removeBinding'! > > > /Peter > > > [*] ...The new <-> delete rule is from C++, in qooxdoo it might be: > "who says 'new' should say '_disposeObjects' or 'set it to null' > depending > on whether it's a descendant of qx.core.Object or a native JavaScript > Object, or '_disposeArray' if it is an Array containing qx.core.Object > object, or '_disposeMap' if it is a native JavaScript Object which values > contain qx.core.Object objects". > ...which I found a little to complicated ;) > > > On 11/28/2013 2:54 PM Marc Puts wrote: >> Hi Dietrich, >> >> Have you tried myWindowInstance.destroy() ? >> >> As a rule of thumb, when you want to dispose of a descendent of >> qx.ui.core.Widget (which the Window is) you should use .destroy() >> instead of .dispose(). >> The difference is that destroy() will also remove the widget from its >> parent and the layouting system. >> >> Regards, >> Marc >> >> On 28-11-13 12:54, Dietrich Streifert wrote: >>> as per a simple code review the destructur of qx.ui.window.Window should be: >>> >>> /* >>> ***************************************************************************** >>> DESTRUCTOR >>> ***************************************************************************** >>> */ >>> destruct : function() { >>> this.removeListener("mousedown", this._onWindowMouseDown); >>> this.removeListener("focusout", this._onWindowFocusOut); >>> >>> qx.core.Init.getApplication().getRoot().remove(this); >>> qx.ui.core.FocusHandler.getInstance().removeRoot(this); >>> } >>> >>> >>> Am 28.11.2013 12:09, schrieb Dietrich Streifert: >>>> Hi all, >>>> >>>> I'm currently struggling with manual disposal of qx.ui.window.Window >>>> instances. >>>> >>>> I'm calling >>>> >>>> myWindowInstance.dispose(); >>>> >>>> which seems to leave the instance attached to the application root, >>>> because in qx.ui.window.Window constructur the instance get >>>> automatically added (from source of qx.ui.window.Window constructor:) >>>> >>>> // Automatically add to application root. >>>> qx.core.Init.getApplication().getRoot().add(this); >>>> >>>> This connection is not removed in qx.ui.window.Window as there is no >>>> destruct method defined. >>>> >>>> So this sums up into two questions: >>>> >>>> 1. Shouldn't qx.ui.window.Window have a destruct method? >>>> 2. Should this destruct method contain >>>> qx.core.Init.getApplication().getRoot().remove(this); >>>> >>>> Thank you for your help. >>>> >>>> Regards >>>> Dietrich >>>> ------------------------------------------------------------------------------ Rapidly troubleshoot problems before they affect your business. Most IT organizations don't have a clear picture of how application performance affects their revenue. With AppDynamics, you get 100% visibility into your Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro! http://pubads.g.doubleclick.net/gampad/clk?id=84349351&iu=/4140/ostg.clktrk _______________________________________________ qooxdoo-devel mailing list qooxdoo-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel