detaching a MapWidget

Hi all,
I’m kind of frustrated not finding a solution for this annoying problem.

I have an app with a MapWidget (Google Map Gwt component), everything works great, but if I close the tab (com.smartgwt.client.widgets.tab.Tab) that has the MapWidget, when I reload the app in the hosted mode, in the shell I receive:

java.lang.AssertionError: A widget in the detach list was found not attached to the document. The is likely caused by wrapping an existing element and removing it from the document without calling RootPanel.detachNow().

With firefox I don’t receive errors at all, but in IE after closing the tab (only the one with the MapWidget), nothing keep working.

I tried different solutions, but even calling RootPanel.detachNow(mapWidget) in the CloseClickHandler of TabSet doesn’t work: Uncaught JavaScript exception [_1 has no properties] (_1 is the TabSet).

I’m using last cvn release.
I ran out of ideas, anyone has any?
Thanks.

Have you already tried calling clear() on the SmartGWT object that contains the MapWidget from the CloseClick handler?

If you’ve done that and still see an error, it’s likely that the error is spurious.

Thanks,
I just tried, but no luck.
I tried destroy, clear, detachOnWindowClose, detachNow.. no results.

Very frustrating.. what do u mean by spurious? Caused by some other stuff? I guess it’s not, I eliminated everything else…

Thanks.

“Spurious” in the sense that GWT may be reporting a leak that isn’t real. But it’s not completely clear.

Can you show a stack trace or test case from your attach to call detachNow() manually yourself? That’s also an approach that should work.

Thanks for reply,

A strange behaviour: the problem occurs just if the tab with the MapWidget is showed to the user (he select the tab): if a tab with the mapWidget is created, but never selected, the problem doesn’t occur!
What change if the user select the tab is that mapWidget.isAttached() starts to return true (false before).
But the error happens even if:

  • user selects the tab with the mapWidget
  • I call mapWidget.removeFromParent() (so mapWidget.isAttached() returns to return false) !!

Here’s the code with last smartgwt and gwt1.5.3.

– TestTab.java:

package client;

import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.maps.client.MapWidget;
import com.google.gwt.user.client.ui.RootPanel;
import com.smartgwt.client.widgets.Canvas;
import com.smartgwt.client.widgets.tab.Tab;
import com.smartgwt.client.widgets.tab.TabSet;
import com.smartgwt.client.widgets.tab.events.CloseClickHandler;
import com.smartgwt.client.widgets.tab.events.TabCloseClickEvent;

public class TestTab implements EntryPoint, CloseClickHandler {
Canvas canvasMapWidget = new Canvas();

public void onModuleLoad() {

	MapWidget mapWidget = new MapWidget();
	mapWidget.setSize("100%", "100%");

	canvasMapWidget.addChild(mapWidget);

	Tab tab = new Tab("home");
	Tab tabMap = new Tab("mapWidget");
	tabMap.setPane(canvasMapWidget);
	tabMap.setCanClose(true);

	TabSet tabSet = new TabSet();
	tabSet.addCloseClickHandler(this);
	tabSet.setSize("800px", "600px");
	tabSet.addTab(tab);
	tabSet.addTab(tabMap);

	RootPanel.get().add(tabSet);
}

public void onCloseClick(TabCloseClickEvent event) {
	canvasMapWidget.clear();
}

}

– TestTab.gwt.xml
<module>
<inherits name=‘com.google.gwt.user.User’/>
<inherits name=“com.google.gwt.maps.GoogleMaps” />
<inherits name=“com.smartgwt.SmartGwt”/>
<inherits name=‘com.google.gwt.user.theme.standard.Standard’/>
<entry-point class=‘client.TestTab’/>
<script src=“http://maps.google.com/maps?gwt=1&file=api&v=2”></script>
</module>

With or without the CloseClickHandler, same problem after refreshing the page: (java.lang.AssertionError: A widget in the detach list was found not attached to the document. The is likely caused by wrapping an existing element and removing it from the document without calling RootPanel.detachNow().)

Thanks.

You mentioned previously that calling detachNow() yourself had actually led to a JavaScript Exception - are you still seeing this and can you provide a stack trace for that Exception (use the SmartClient Developer Console in IE and any time a JavaScript error occurs, stack traces appear in the Results tab).

Thanks,

I was thinking that, cause on hosted mode I had an error, it was the same that make IE not working properly, but actually it isn’t.

In hosted mode, but just with GWT1.5, after removing a tab with a MapWidget I received this error after refreshing the page:

java.lang.AssertionError: A widget in the detach list was found not attached to the document. The is likely caused by wrapping an existing element and removing it from the document without calling RootPanel.detachNow().

In the console nothing is shown because happens on reloading the page.

But in IE (I didn’t realize I can see the dev console even there) after removing a tab with a mapWidget, if i click anywhere in the page, I see this error (Im using GWT16 now):

20:21:25.440:MUP7:WARN:Log:Error:
‘Errore non specificato.’
in http://21.241.49.29:8080/Wwwar.html
at line 1634
Element.$yw(_1=>“left”, _2=>[DIVElement]{ID:isc_3J}, _3=>[BODYElement]{nodeName:BODY}, _4=>false)
Element.$s4(_1=>[DIVElement]{ID:isc_3J}, _2=>[BODYElement]{nodeName:BODY}, _3=>false)
Canvas.$s4(_1=>undef)
“if(_1==null)_1=this.getDocumentBody();var _2=this.ns.Element.$s4(this.getClipHandle(),_1,this.isRTL());return _2”
Canvas.getPageLeft()
Canvas.containsPoint(_1=>983, _2=>80, _3=>false)
Canvas.visibleAtPoint(_1=>983, _2=>80, _3=>undef, _4=>undef)
EventHandler.$k5(_1=>Obj{type:error}, _2=>undef)
EventHandler.handleMouseUp(_1=>Obj{type:error}, _2=>undef)
EventHandler.dispatch(_1=>EventHandler.handleMouseUp(), _2=>Obj{type:error})
anonymous(event=>undef)
“var returnVal=arguments.callee.$ch.isc.EH.dispatch(arguments.callee.$j2,event);return returnVal;”

no way I can understand it..

Are you able in any way to understand this error?
Thanks again.

This appears related to this GWT integration related issue. Please attach your standalone test case there, and star the issue. We’ll look into it.

Hi smartgwt.dev, I would love to help and make you able to help me, but are you sure that’s the correct issue link? Doesn’t seems too related to me, but maybe you know what’s behind the scene.
To summarize, i have, just on IE, that error on clicking anywhere in the page, after removing a tab with a MapWidget in it.

Thanks.

okay, then please create a new issue, along with a standalone testcase.

Thanks.