swiz/swiz-framework — Issue #29: Views set up manually with BeanEvent.SET_UP_BEAN are not automatically torn down
Author: bclinkinbeard
Created: 2011-12-19 18:47:09+00:00
State: open

**Migrated from SWIZ-60**

Going through SET_UP_BEAN does not add the view to the wired views map, so when it is removed from stage it will not be automatically torn down because it's not in wiredViews.

Possible fix in handleBeanEvent():

case BeanEvent.SET_UP_BEAN:
if( existingBean )
if( existingBean.initialized )
logger.warn( "{0} is already set up as a bean. Ignoring SET_UP_BEAN request.", event.source.toString() );
else if( event.source is DisplayObject && event.source is ISetUpValidator )
SwizManager.setUp( DisplayObject( event.source) );
else
setUpBean( existingBean );
else
setUpBean( constructBean( event.source, event.beanName, swiz.domain ) );
break;

Which would seem to work since SwizManager.setUp() won't do anything with the view if it is already in the wired views list, and assuming that a DisplayObject implementing ISetUpValidator is infered to be a view that the developer is attempting to manually set up themselves.