If you are going to be removing existing RootPanels from the DOM implicitly
(i.e. by removing one of their parent elements), you're going to have to
call RootPanel.detachNow() on them. The reason this is necessary is that
otherwise they will be "orphaned", meaning that they're out of the DOM, but
neither they nor their child widgets are aware of having been removed. This
can break a number of things, including potentially creating leaks. That's
also why the assertion in detachWidgets() is necessary -- I would prefer to
be able to throw an exception when the problem is created (i.e. when the
parent element is removed from the DOM), but there's no way to receive
notification of this.

On Mon, Sep 22, 2008 at 4:57 PM, Ed <[EMAIL PROTECTED]> wrote:

>
> He Joel,
>
> Just a tinny problem I am still stuck with:
> In your example above, the replaced content, contains a few more
> RootPanels like this:
> ...>
>  <div id='stuff'>
>    <... stuff ...>
>     <div id='rootPanela'>
>      ....
>     <div id='rootPanelb'>
>  </div>
> <...>
>
> What I do: replacing the content of id="stuff" with some HTML widget
> when the user presses a button, like you describe above. When the user
> clicks another button, I put back the original content.
> However, the original content contains some html snippets that are
> loaded with a RootPanel (for example to add some Form).
> If the user clicks a button such that the original content is
> replaced, such that the RootPanels are put aside and not attached to
> the body, the new code (I think it's even your code ;)) in RootPanel:
> detachWidgets will throw an Assert exception when the hosted browser
> is refreshed at that moment, as these Rootpanels aren't attached to
> the Body and the RootPanel will try to remove it when the window
> closes.
>
> Any idea how to solve this?
> I could remove these RootPanels from the widgetsToDetach in the
> RootPanel when they are put aside, but I don't know the exact
> RootPanel beforehand and I don't like this solution as it avoids my
> code from being losely coupled...
>
> Is this exception realy a possible memory leak? And might it not a bit
> too tight (the exception)
>
>
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
http://groups.google.com/group/Google-Web-Toolkit-Contributors
-~----------~----~----~----~------~----~------~--~---

Reply via email to