tag:robotlegs.tenderapp.com,2009-10-18:/discussions/problems/2777-mediator-destroyed-right-after-being-initializedRobotlegs: Discussion 2013-07-09T13:44:57Ztag:robotlegs.tenderapp.com,2009-10-18:Comment/275161422013-06-27T14:07:54Z2013-06-27T14:07:54ZMediator destroyed right after being initialized<div><p>Hello,</p>
<blockquote>
<p>The problem is that the Mediator gets destroyed right after
being initialized and in the stack I can see that
"onRemovedFromStage" is called from robotlegs</p>
</blockquote>
<p>My first thought is that there might be some re-parenting issues
– the view being added to another container right after it
has been added to the stage.<br>
I couldn’t make your app work, because of the missing
classes. I took a look at the code, but I can’t see
what’s wrong. Perhaps I’m just blind today ;)</p>
<blockquote>
<p>questRobotlegs = new CareerQuestContext(); questUIComponent =
new UIComponent();<br>
questUIComponent.addChild(questRobotlegs as Sprite);<br>
popupCanvas.addChildAt(questUIComponent,0);</p>
</blockquote>
<p>Now, the above snippet is not included in your code, but it
looks like a re-parenting issue after all. When questRobotlegs is
added to your questUIComponent, your AnchorBarView gets
re-parented, after it was added to questRobotlegs.</p>
<p>If that’s not the issue, I suggest trying to add a simple
view instead of your AnchorBarView, not extending anything and not
using a factory or alike, to see what happens.</p>
<p>I see you use an older version of rl2.<br>
If you decide to use the rl2 release build you’ll need to do
it like so:<br>
_context.afterInitializing(initAnchorBar);</p>
<p>Just for your information: if autoRemove is set to false, the
mediator won’t be removed automatically. Of course,
you’ll have to remove it yourself, if need be.</p>
<p>
mediatorMap.map(SomeView).toMediator(SomeMediator).autoRemove(false);</p>
<p>I don’t know if that solves your problem though.</p></div>Ondina D.F.tag:robotlegs.tenderapp.com,2009-10-18:Comment/275161422013-06-27T15:47:37Z2013-06-27T15:47:37ZMediator destroyed right after being initialized<div><blockquote>
<p>if in the mediator I use
view.addEventListener(CareerEvent.OPEN_POPUP,passEvent); instead of
addViewListener than robotlegs tries to destroy it but it
fails.</p>
</blockquote>
<p>If you add event listeners using addViewListener, the listeners
are removed automatically by robotlegs when the mediator is
destroyed. That’s not the case for event listeners added
directly to the view. If you don’t remove the listeners
manually, they can keep a reference to the view; views and/or
mediators are therefore not eligible for gc. It’s a common
cause for memory leaks. You sureley don’t want to use it as a
workaround for your problem;)</p></div>Ondina D.F.tag:robotlegs.tenderapp.com,2009-10-18:Comment/275161422013-07-02T06:56:01Z2013-07-02T06:56:01ZMediator destroyed right after being initialized<div><p>Have you sorted this out? Can the thread be closed?</p></div>Ondina D.F.