Lisichenko / as3isolib

Automatically exported from code.google.com/p/as3isolib
0 stars 0 forks source link

IsoScene.removeChildByID not testing for null result #14

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
I'm concerned that calling myScene.removeChildByID(id)   will still 
invalidate a scene even if the child does not exist, which would be non-
ideal.

Here's the code in question, from IsoScene.as:

override public function removeChildByID (id:String):INode
       {
           var child:INode = super.removeChildByID(id);
           child.removeEventListener(IsoEvent.INVALIDATE, 
child_invalidateHandler);
                     _isInvalidated = true;
                     return child;
       }

I haven't tested but expect the above code to fail when the call 
removeEventListener is performed on a null object.

Original issue reported on code.google.com by hello.ja...@gmail.com on 22 Apr 2009 at 4:54

GoogleCodeExporter commented 8 years ago

Here's a possible patch:

override public function removeChildByID (id:String):INode
{
    var child:INode = super.removeChildByID(id);

    if ( child ) {
        child.removeEventListener(IsoEvent.INVALIDATE, child_invalidateHandler);
        _isInvalidated = true;
    }

    return child;
}

Original comment by hello.ja...@gmail.com on 22 Apr 2009 at 4:57

GoogleCodeExporter commented 8 years ago

Original comment by jwopitz on 22 Apr 2009 at 10:36

GoogleCodeExporter commented 8 years ago

Original comment by jwopitz on 4 May 2009 at 8:05