how do I dispose a qx.ui.window.Window in qx 3.0.1?

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

how do I dispose a qx.ui.window.Window in qx 3.0.1?

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
[hidden email]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
Reply | Threaded
Open this post in threaded view
|

Re: how do I dispose a qx.ui.window.Window in qx 3.0.1?

Dietrich Streifert
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
[hidden email]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
Reply | Threaded
Open this post in threaded view
|

Re: how do I dispose a qx.ui.window.Window in qx 3.0.1?

Marc Puts
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
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel


------------------------------------------------------------------------------
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
[hidden email]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
Reply | Threaded
Open this post in threaded view
|

Re: how do I dispose a qx.ui.window.Window in qx 3.0.1?

Peter Schneider
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
[hidden email]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
Reply | Threaded
Open this post in threaded view
|

Re: how do I dispose a qx.ui.window.Window in qx 3.0.1?

Dietrich Streifert
In reply to this post by Marc Puts
Hi Marc,

Thank you for the hint.

But for my use case I need a synchronous dispose. destruct is
asynchronous, as the object to be disposed is enqueued into the Dispose
queue:

https://github.com/qooxdoo/qooxdoo/blob/release_3_0_1/framework/source/class/qx/ui/core/Widget.js#L3772


Am 28.11.2013 14:54, schrieb Marc Puts:

> 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


------------------------------------------------------------------------------
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
[hidden email]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
Reply | Threaded
Open this post in threaded view
|

Re: how do I dispose a qx.ui.window.Window in qx 3.0.1?

Varol Okan
In reply to this post by Peter Schneider
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
[hidden email]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
Reply | Threaded
Open this post in threaded view
|

Re: how do I dispose a qx.ui.window.Window in qx 3.0.1?

Dietrich Streifert
In reply to this post by Dietrich Streifert
One solution remains:

myWindowInstance.destory()
qx.ui.core.queue.Dispose.flush();

But this feels somehow "inelegant".

Any help from the qooxdoo staff would be great.

Regards
Dietrich


Am 28.11.2013 17:24, schrieb Dietrich Streifert:

> Hi Marc,
>
> Thank you for the hint.
>
> But for my use case I need a synchronous dispose. destruct is
> asynchronous, as the object to be disposed is enqueued into the
> Dispose queue:
>
> https://github.com/qooxdoo/qooxdoo/blob/release_3_0_1/framework/source/class/qx/ui/core/Widget.js#L3772 
>
>
>
> Am 28.11.2013 14:54, schrieb Marc Puts:
>> 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
>


------------------------------------------------------------------------------
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
[hidden email]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
Reply | Threaded
Open this post in threaded view
|

Re: how do I dispose a qx.ui.window.Window in qx 3.0.1?

MartinWittemann
Administrator
Hello Dietrich,

> One solution remains:
>
> myWindowInstance.destory()
> qx.ui.core.queue.Dispose.flush();
>
> But this feels somehow "inelegant".
>
> Any help from the qooxdoo staff would be great.

We recommend to use destroy for all widgets. Its the best way to make sure every code part we have written to get rid of the widget is executed. But as you said, its async and if you need it to be sync, you can take that „inelegant“ way, where I agree on the term of inelegant in that case. ;)
I also agree on the rules peter mentioned in a common case. In the particular case its a bit more complicated because our HTML element usually takes care of removing the listener and the widget itself takes care of removing itself from its parent. This brings some convenience but on the other hand we loos some clarity of what needs to be disposed and what does the system automatically clean up. So I guess I won’t be happy with either of the two alternatives. ;)

Regards,
Martin
------------------------------------------------------------------------------
Sponsored by Intel(R) XDK
Develop, test and display web and hybrid apps with a single code base.
Download it for free now!
http://pubads.g.doubleclick.net/gampad/clk?id=111408631&iu=/4140/ostg.clktrk
_______________________________________________
qooxdoo-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel