PDA

View Full Version : Crash when removing a gxt composite from a RootPanel (reproducible)



googelybear
10 Sep 2009, 1:36 AM
Hi,

today I made a very nasty discovery: It seems to be impossible to remove a com.extjs.gxt.ui.client.widget.Composite from a RootPanel with RootPanel.clear().

What you get is this nice stacktrace:

2009-09-10 11:22:25,767 [FATAL] Uncaught Exception:
com.google.gwt.core.client.JavaScriptException:
(TypeError): this.removeChild is not a function
fileName: jar:file:/opt/gwt-linux-1.7.0/gwt-user.jar!/com/google/gwt/dom/client/Node.java
lineNumber: 202
stack: ([object HTMLDivElement])@jar:file:/opt/gwt-linux-1.7.0/gwt-user.jar!/com/google/gwt/dom/client/Node.java:202
static void com.google.gwt.user.client.DOM.dispatchEvent(com.google.gwt.user.client.Event,com.google.gwt.user.client.Element,com.google.gwt.user.client.EventListener)([object Event],[object HTMLDivElement],[object gwt_nativewrapper_class])@:0
([object Event])@jar:file:/opt/gwt-linux-1.7.0/gwt-user.jar!/com/google/gwt/user/client/impl/DOMImplStandard.java:177
@:0

at com.google.gwt.dom.client.Node$.removeChild$(Native Method)
at com.google.gwt.user.client.DOM.removeChild(DOM.java:992)
at com.google.gwt.user.client.ui.ComplexPanel.remove(ComplexPanel.java:61)
at com.google.gwt.user.client.ui.AbsolutePanel.remove(AbsolutePanel.java:136)
at com.google.gwt.user.client.ui.WidgetCollection$WidgetIterator.remove(WidgetCollection.java:55)
at com.google.gwt.user.client.ui.Panel.clear(Panel.java:74)Debbugging this showed that the DOM implementation cannot find the parent of the composite (in this case the rootPanel) anymore: DOM.getParent(composite) returns null.
If I change the Composite into a LayoutContainer this works.

To reproduce try it with the following code:

public class CompositeCrasher extends com.extjs.gxt.ui.client.widget.Composite {

VerticalPanel panel;

public CompositeCrasher() {

panel = new VerticalPanel();
panel.setSize(300, 300);
panel.add(new Html("I crash"));
initComponent(panel);
}
}


public class Crasher implements EntryPoint {

public void onModuleLoad() {
RootPanel rootPanel = RootPanel.get();
rootPanel.add(new CompositeCrasher());
rootPanel.clear();
}
}Is this a bug in gxt?

sven
10 Sep 2009, 5:01 AM
Yes it is. I run over it just two days ago and already have a fix for this. I will report back as soon as i commited it.

Your testcase works great with this fix.

sven
10 Sep 2009, 7:19 AM
Fixed in SVN

googelybear
10 Sep 2009, 11:26 PM
great - that was quick ;-)

kulnor
23 Nov 2009, 2:01 PM
Sven:
am I right to assume that this is now available in the 2.0.4 release? Was using the open source version but just signed up for the Silver support package as I need this fix.
thanks
*K

cimballi
16 Jun 2010, 12:49 PM
Sven, can you precise the version in which the bug is corrected as I have the same problem with the 2.1.1. Thanks !

cimballi
16 Jun 2010, 12:57 PM
Sven, in fact the problem I encoutered was with a com.google.gwt.user.client.ui.Composite, it works with a com.extjs.gxt.ui.client.widget.Composite.

abshnasko
29 Nov 2011, 2:45 PM
Same problem in 2.2.5

Caused by: com.google.gwt.core.client.JavaScriptException: (TypeError): this.removeChild is not a function at com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:248) at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:136) at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:561) at com.google.gwt.dev.shell.ModuleSpace.invokeNativeObject(ModuleSpace.java:269) at com.google.gwt.dev.shell.JavaScriptHost.invokeNativeObject(JavaScriptHost.java:91) at com.google.gwt.dom.client.Node$.removeChild$(Node.java) at com.google.gwt.user.client.DOM.removeChild(DOM.java:1023) at com.google.gwt.user.client.ui.ComplexPanel.remove(ComplexPanel.java:71) at com.google.gwt.user.client.ui.AbsolutePanel.remove(AbsolutePanel.java:199) at com.google.gwt.user.client.ui.WidgetCollection$WidgetIterator.remove(WidgetCollection.java:55) at com.google.gwt.user.client.ui.Panel.clear(Panel.java:78)