删除嵌套视图时RobotLegs出错

时间:2013-08-09 15:25:52

标签: flex robotlegs

我们可能会稍微不寻常地设置,其中上下文父子关系与显示列表无关。每个视图都加载到ViewLoader中,ViewLoader使用以下扩展名设置视图的上下文:

    public function extend(context:IContext):void
    {
        context.install( 
            TraceLoggingExtension,
            VigilanceExtension,
            InjectableLoggerExtension,
            ContextViewExtension,
            EventDispatcherExtension,
            DirectCommandMapExtension,
            EventCommandMapExtension,
            LocalEventMapExtension,
            ViewManagerExtension,
            StageObserverExtension,
            MediatorMapExtension,
            ViewProcessorMapExtension,
            StageCrawlerExtension,
            StageSyncExtension
        ).install( new ModularityExtension(false, true) );

        context.configure( ContextViewListenerConfig );

        var viewProcessor:IViewProcessorMap = context.injector.getInstance( IViewProcessorMap );
        viewProcessor.map( IViewLoader ).toProcess( new MediatorCreator( ViewLoaderMediator ));

    }

一切正常。但是,当嵌套两个视图,并从舞台中删除父视图时,我在viewProcessor中为子视图的上下文收到以下错误:

TypeError: Error #1006: value is not a function.
    at robotlegs.bender.extensions.viewProcessorMap.impl::ViewProcessorFactory/runAllUnprocessors()[/Development/Projects/Robotlegs/robotlegs-framework/src/robotlegs/bender/extensions/viewProcessorMap/impl/ViewProcessorFactory.as:92]
    at robotlegs.bender.extensions.viewProcessorMap::ViewProcessorMapExtension/beforeDestroying()[/Development/Projects/Robotlegs/robotlegs-framework/src/robotlegs/bender/extensions/viewProcessorMap/ViewProcessorMapExtension.as:72]
    at MessageRunner/next()[/Development/Projects/Robotlegs/robotlegs-framework/src/robotlegs/bender/framework/impl/MessageDispatcher.as:152]
    at MessageRunner/run()[/Development/Projects/Robotlegs/robotlegs-framework/src/robotlegs/bender/framework/impl/MessageDispatcher.as:135]
    at robotlegs.bender.framework.impl::MessageDispatcher/dispatchMessage()[/Development/Projects/Robotlegs/robotlegs-framework/src/robotlegs/bender/framework/impl/MessageDispatcher.as:87]
    at robotlegs.bender.framework.impl::LifecycleTransition/enter()[/Development/Projects/Robotlegs/robotlegs-framework/src/robotlegs/bender/framework/impl/LifecycleTransition.as:191]
    at robotlegs.bender.framework.impl::Lifecycle/destroy()[/Development/Projects/Robotlegs/robotlegs-framework/src/robotlegs/bender/framework/impl/Lifecycle.as:173]
    at robotlegs.bender.framework.impl::Context/destroy()[/Development/Projects/Robotlegs/robotlegs-framework/src/robotlegs/bender/framework/impl/Context.as:183]
    at robotlegs.bender.extensions.contextView::StageSyncExtension/onRemovedFromStage()[/Development/Projects/Robotlegs/robotlegs-framework/src/robotlegs/bender/extensions/contextView/StageSyncExtension.as:92]
    at flash.display::DisplayObjectContainer/removeChild()
    at mx.core::UIComponent/http://www.adobe.com/2006/flex/mx/internal::$removeChild()[/Users/justinmclean/Documents/ApacheFlexSDK/frameworks/projects/framework/src/mx/core/UIComponent.as:7312]
    at mx.core::UIComponent/removeChild()[/Users/justinmclean/Documents/ApacheFlexSDK/frameworks/projects/framework/src/mx/core/UIComponent.as:7219]
    at spark.components::Group/http://www.adobe.com/2006/flex/mx/internal::elementRemoved()[/Users/justinmclean/Documents/ApacheFlexSDK/frameworks/projects/spark/src/spark/components/Group.as:1732]
    at spark.components::Group/removeElementAt()[/Users/justinmclean/Documents/ApacheFlexSDK/frameworks/projects/spark/src/spark/components/Group.as:1479]
    at spark.components::Group/removeAllElements()[/Users/justinmclean/Documents/ApacheFlexSDK/frameworks/projects/spark/src/spark/components/Group.as:1498]
    at ViewLoader/applyViewImpl()
    at ViewLoader/commitProperties()
    at mx.core::UIComponent/validateProperties()[/Users/justinmclean/Documents/ApacheFlexSDK/frameworks/projects/framework/src/mx/core/UIComponent.as:8227]
    at mx.managers::LayoutManager/validateProperties()[/Users/justinmclean/Documents/ApacheFlexSDK/frameworks/projects/framework/src/mx/managers/LayoutManager.as:605]
    at mx.managers::LayoutManager/doPhasedInstantiation()[/Users/justinmclean/Documents/ApacheFlexSDK/frameworks/projects/framework/src/mx/managers/LayoutManager.as:821]
    at mx.managers::LayoutManager/doPhasedInstantiationCallback()[/Users/justinmclean/Documents/ApacheFlexSDK/frameworks/projects/framework/src/mx/managers/LayoutManager.as:1188]

我已经尝试强制在父级之前删除子级,但这并不能防止错误。

1 个答案:

答案 0 :(得分:0)

问题是由多个调解器映射到每个ViewLoader引起的。当Viewloader嵌套两次时,两个祖先上下文都会添加映射。这是一个简单的解决方法,可以在任何地方使用相同的MediatorCreator实例,它可以自行管理。