How to use dynamic decorators in qooxdoo 3.0 - Episode 2

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

How to use dynamic decorators in qooxdoo 3.0 - Episode 2

cyrillerigault
Hello,

See my previous mail sent this saturday Oct 26, 2013 at 1:30 pm concerning the problem.

I spent my saturday understanding how the new Decorator model works in Qooxdoo 3.0, and understood why dynamic decorators don't work. Here are the issues I found:


- first issue - dispose an old decorator before assigning a new one
If the decorator is disposed before assigning the new one to the component, the component _applyDecorator() method calls getCssClassName() on a disposed object, which returns qx-undefined, and the old decorator class is not removed from the component

- second dissue - dispose an old decorator after assigning a new one
In qooxdoo 3.0, the decorator class is removed from the HTML component, but not from the style sheet.
As object hashes are re-used from disposed objects, a new decorator may use a hash from a disposed decorator.
When so, the new decorator will have the same css classname as the disposed one, and when Widget._applyDecorator() calls qx.theme.manager.Decoration.addCssClass(), the new decorator properties will not be applied, as they already exist in the style sheet for this hash.
So, the new decorator properties will not be applied !

Here is how I temporarily? solved the problem:
- I use a subclassed version of qx.ui.decoration.Decorator, that only defines a destructor which:
. gets the selector of the decorator to dispose
. removes the selector from the style sheet
destruct : function() {
    var selector = "."+qx.theme.manager.Decoration.getInstance().getCssClassName(this);
    qx.ui.style.Stylesheet.getInstance().removeRule( selector);
  }
- I only dispose an old decorator after assigning the new one to the widget.

I hope everything was clear. I don't know if this solution is fine. I'm waiting for some feedback now. Maybe better solutions exist.

Regards,

Cyrille




------------------------------------------------------------------------------
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60135991&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 to use dynamic decorators in qooxdoo 3.0 - Episode 2

Thomas Herchenroeder
Cyrille,

please open Bugzilla bugs for both issues. Attach patches as appropriate.

Thanks,
T.

On 10/26/2013 06:21 PM, Cyrille Rigault wrote:
Hello,

See my previous mail sent this saturday Oct 26, 2013 at 1:30 pm concerning the problem.

I spent my saturday understanding how the new Decorator model works in Qooxdoo 3.0, and understood why dynamic decorators don't work. Here are the issues I found:


- first issue - dispose an old decorator before assigning a new one
If the decorator is disposed before assigning the new one to the component, the component _applyDecorator() method calls getCssClassName() on a disposed object, which returns qx-undefined, and the old decorator class is not removed from the component

- second dissue - dispose an old decorator after assigning a new one
In qooxdoo 3.0, the decorator class is removed from the HTML component, but not from the style sheet.
As object hashes are re-used from disposed objects, a new decorator may use a hash from a disposed decorator.
When so, the new decorator will have the same css classname as the disposed one, and when Widget._applyDecorator() calls qx.theme.manager.Decoration.addCssClass(), the new decorator properties will not be applied, as they already exist in the style sheet for this hash.
So, the new decorator properties will not be applied !

Here is how I temporarily? solved the problem:
- I use a subclassed version of qx.ui.decoration.Decorator, that only defines a destructor which:
. gets the selector of the decorator to dispose
. removes the selector from the style sheet
destruct : function() {
    var selector = "."+qx.theme.manager.Decoration.getInstance().getCssClassName(this);
    qx.ui.style.Stylesheet.getInstance().removeRule( selector);
  }
- I only dispose an old decorator after assigning the new one to the widget.

I hope everything was clear. I don't know if this solution is fine. I'm waiting for some feedback now. Maybe better solutions exist.

Regards,

Cyrille





------------------------------------------------------------------------------
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from 
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60135991&iu=/4140/ostg.clktrk


_______________________________________________
qooxdoo-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel


------------------------------------------------------------------------------
Android is increasing in popularity, but the open development platform that
developers love is also attractive to malware creators. Download this white
paper to learn more about secure code signing practices that can help keep
Android apps secure.
http://pubads.g.doubleclick.net/gampad/clk?id=65839951&iu=/4140/ostg.clktrk
_______________________________________________
qooxdoo-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel