Awesome, thanks!
-deech

On Wed, Dec 1, 2010 at 4:04 PM, Tamási János <[email protected]> wrote:
> Initialize the array in the constructor to avoid the sharing.
>
> http://manual.qooxdoo.org/1.2.x/pages/core/classes.html (primitive types
> vs. reference types)
>
> 2010-12-01 22:47 keltezéssel, aditya siram írta:
>> Hi all,
>> I am getting weird behavior using array properties in Qooxdoo 1.2. It
>> seems as though the array properties of a given class are shared
>> between instances of the class.
>>
>> For example, given the following test class:
>>
>>   qx.Class.define("scratch.Test",
>>   {
>>       extend : qx.core.Object,
>>       construct : function (text){
>>           this.getText().push(text);
>>       },
>>       properties : {
>>           text : {
>>               init : []
>>           }
>>       }
>>   })
>>
>>
>> And the main class:
>>   qx.Class.define("scratch.Application",
>>     {
>>             test1 = new scratch.Test("hello");
>>             test2 = new scratch.Test("world");
>>             console.log(test1.getText() + " " + test2.getText());
>>      });
>>
>> Console output is :
>> hello,world hello,world
>>
>> *However* if I use qx.type.Array, this problem goes away. So changing
>> the test class to :
>>   qx.Class.define("scratch.Test",
>>   {
>>       extend : qx.core.Object,
>>       construct : function (text){
>>           this.initText(new qx.type.Array());
>>           this.getText().push(text);
>>       },
>>       properties : {
>>           text : {
>>               deferredInit : true
>>           }
>>       }
>>   })
>>
>> And the main class to :
>>
>>   qx.Class.define("scratch.Application",
>>     {
>>             test1 = new scratch.Test("hello");
>>             test2 = new scratch.Test("world");
>>             console.log(test1.getText().toString() + " " +
>> test2.getText().toString());
>>      });
>>
>> Gives the correct behavior:
>> hello world
>>
>> Any ideas?
>> Thanks!
>> -deech
>>
>> ------------------------------------------------------------------------------
>> Increase Visibility of Your 3D Game App & Earn a Chance To Win $500!
>> Tap into the largest installed PC base & get more eyes on your game by
>> optimizing for Intel(R) Graphics Technology. Get started today with the
>> Intel(R) Software Partner Program. Five $500 cash prizes are up for grabs.
>> http://p.sf.net/sfu/intelisp-dev2dev
>> _______________________________________________
>> qooxdoo-devel mailing list
>> [email protected]
>> https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
>
>
> ------------------------------------------------------------------------------
> Increase Visibility of Your 3D Game App & Earn a Chance To Win $500!
> Tap into the largest installed PC base & get more eyes on your game by
> optimizing for Intel(R) Graphics Technology. Get started today with the
> Intel(R) Software Partner Program. Five $500 cash prizes are up for grabs.
> http://p.sf.net/sfu/intelisp-dev2dev
> _______________________________________________
> qooxdoo-devel mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
>

------------------------------------------------------------------------------
Increase Visibility of Your 3D Game App & Earn a Chance To Win $500!
Tap into the largest installed PC base & get more eyes on your game by
optimizing for Intel(R) Graphics Technology. Get started today with the
Intel(R) Software Partner Program. Five $500 cash prizes are up for grabs.
http://p.sf.net/sfu/intelisp-dev2dev
_______________________________________________
qooxdoo-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel

Reply via email to