tag:robotlegs.tenderapp.com,2009-10-18:/discussions/problems/219-browser-rezise-breaks-eventcommand-mapping-in-a-moduleRobotlegs: Discussion 2018-10-18T16:35:20Ztag:robotlegs.tenderapp.com,2009-10-18:Comment/38880242010-11-19T11:16:05Z2010-11-19T11:16:07ZBrowser rezise breaks Event/Command mapping in a Module<div><p>Hey guys,</p>
<p>Thank you for reading this. We are using Robotlegs 1.1 with Joel Hooks modular utility to build an application and have spotted a bug.</p>
<p>When browser is resized manually, this seems to completely break the mapping of Commands to Events inside a loded module Context. Modules load into a TabNavigator, so re-loading the broken module re-maps everything when Context.startup() is run again. However re-sizing browser again inevitably leads to the same failure.</p>
<p>Has anybody come across this strange behaviour?</p>
<p>Many thanks.</p>
<p>Igor</p></div>Igor Volktag:robotlegs.tenderapp.com,2009-10-18:Comment/38880242010-11-19T12:49:55Z2010-11-19T12:49:55ZBrowser rezise breaks Event/Command mapping in a Module<div><p>Hi Igor - could you post the code that is breaking (ie your context mapping) - obviously with any sensitive stuff stripped out.</p>
<p>Even better - if you can create a minimal version that demonstrates the breakage, we can take a closer look.</p>
<p>The absolute best - if you can do it - would be a test added to the test suite that currently fails and should pass once the bug is fixed.</p>
<p>Thanks,</p>
<p>Stray</p></div>Straytag:robotlegs.tenderapp.com,2009-10-18:Comment/38880242010-11-19T13:31:58Z2010-11-19T13:31:59ZBrowser rezise breaks Event/Command mapping in a Module<div><p>Hey Stray,</p>
<p>I have just found the reason for this fault. It is nothing to do with RL. Inside each module I had a cleanup() method ModuleMediator unmapping all events, commands, singletons etc when the module is removed. It was previously added to</p>
<p>viewComponent.addEventListener(Event.REMOVED_FROM_STAGE, cleanup);</p>
<p>weirdly this was firing when the application was being resized as part of the browser window. It didn't even occur to me to check for it first.</p>
<p>Now I have changed the above line to:</p>
<p>viewComponent.parent.addEventListener("unload", cleanup, false, 0, true);</p>
<p>parent in this case is ModuleLoader and it all works fine.</p>
<p>Thank you so much for looking into it.</p>
<p>Igor</p></div>Igor Volktag:robotlegs.tenderapp.com,2009-10-18:Comment/38880242010-11-19T14:05:55Z2010-11-19T14:05:55ZBrowser rezise breaks Event/Command mapping in a Module<div><p>Great - glad you found it, and good to have it in the knowledge base for people who have this problem in future.</p>
<p>Thanks,</p>
<p>Stray</p></div>Stray