I don't think this is the right change. My justification:
I guess <textlistitem>#_applystyle() is called on an already destroyed object, you should get a warning like "call to undefined method 'setAttribute' " in swf8. After destroy() is invoked on a <textlistitem>, its _title property is set to 'null', therefore the following call in _applystyle() causes an null-pointer exception:
> this._title.setAttribute('fgcolor', textcolor);

Fixing _applystyle() to catch the NPE is not appropriate in this case, since calling methods on destroyed object is forbidden and leads to undefined behaviour in general.

Covering one place where a null pointer exception occurs when calling a method on a destroyed object, but leaving a dozen of other places with exactly the same behaviour doesn't seem right.
You may ask "dozens"?:
<canvas debug="true">
<list id="mylist" />
<radiogroup>
<radiobutton id="myrbtn"/>
</radiogroup>
<window id="mywindow"/>
<tabslider id="mytslider">
<tabelement id="mytelement"/>
</tabslider>
<menu>
<menuitem command="new lz.command()" id="mymitem"/>
</menu>
<handler name="oninit"><![CDATA[
    var arr = [mylist, myrbtn, mywindow, mytelement, mytslider, mymitem];
    for (var i = 0; i < arr.length; ++i) {
      var c = arr[i];
      if (c is lz.tabslider) {
        // in order to run the code in _applystyle
        c.setAttribute('bgcolor', null);
      }
      c.destroy();
      // setStyle() calls _applystyle() later
      c.setStyle({textcolor: 0});
    }
  ]]></handler>
</canvas>

Ok, this is only half a dozen, but it should be sufficient to point out my concerns.



On 4/20/2010 9:51 PM, Max Carlson wrote:
Change 20100420-maxcarlson-u by maxcarl...@friendly on 2010-04-20 12:49:58 PDT
     in /Users/maxcarlson/openlaszlo/trunk-clean
     for http://svn.openlaszlo.org/openlaszlo/trunk

Summary: Fix NPE in textlistitem

Bugs Fixed: LPP-8880 - ERROR @lz/textlistitem.lzx?23: TypeError: Error #1009 in 
swf10

Technical Reviewer: hminsky
QA Reviewer: ptw

Details: Check _title before dereferencing it.

Tests: See LPP-8880

Files:
M       lps/components/lz/textlistitem.lzx

Changeset: 
http://svn.openlaszlo.org/openlaszlo/patches/20100420-maxcarlson-u.tar


Reply via email to