When I call canvas.addChild (child), child.onInit () is called.
When I call canvas.removeChild (child), child.onDestroy () is NOT called.
Questions:
1. Is this a bug?
2. If this is not a bug, how should I detect that a Canvas is being destroyed?
1. the SmartGWT or SmartClient version and browser version(s) involved;
SmartGWT 2.5
GWT 2.3.0
FireFox 6.0.2
Chrome 15.0.874.120 m
3. for a client-side problem, the contents of the Developer Console (see FAQ for usage);
5. sample code.
When I call canvas.removeChild (child), child.onDestroy () is NOT called.
Questions:
1. Is this a bug?
2. If this is not a bug, how should I detect that a Canvas is being destroyed?
1. the SmartGWT or SmartClient version and browser version(s) involved;
SmartGWT 2.5
GWT 2.3.0
FireFox 6.0.2
Chrome 15.0.874.120 m
3. for a client-side problem, the contents of the Developer Console (see FAQ for usage);
Code:
13:30:28.741:INFO:Log:initialized 13:30:28.749:WARN:Log:NOTE: Firebug is enabled. Firebug greatly slows the performance of applications that make heavy use of JavaScript. Isomorphic highly recommends Firebug for troubleshooting, but Firebug and other development tools should be disabled when assessing the real-world performance of SmartClient applications. 13:30:32.687:INFO:Log:isc.Page is loaded
Code:
import com.smartgwt.client.widgets.IButton; import com.smartgwt.client.widgets.Canvas; import com.smartgwt.client.widgets.layout.VLayout; import com.smartgwt.client.widgets.events.ClickHandler; import com.smartgwt.client.widgets.events.ClickEvent; import com.google.gwt.core.client.EntryPoint; import com.google.gwt.core.client.GWT; public class TestRemoveChild implements EntryPoint { public void onModuleLoad () { // layout upon which to place a Canvas final VLayout canvasLayout = new VLayout (); canvasLayout.setWidth (600); canvasLayout.setHeight (400); canvasLayout.setBackgroundColor ("red"); // create Canvas with opacity final Canvas canvas = new Canvas () { @Override protected void onInit () { GWT.log ("Canvas.onInit ()"); super.onInit (); } @Override protected void onDestroy () { GWT.log ("Canvas.onDestroy ()"); super.onDestroy (); } }; canvas.setBackgroundColor ("blue"); canvas.setLeft (10); canvas.setTop (10); canvas.setWidth (50); canvas.setHeight (50); // add a button that shows a dialog with a canvas with opaticy set final IButton addChildButton = new IButton (); addChildButton.setTitle ("Add Child"); addChildButton.addClickHandler (new ClickHandler () { public void onClick (final ClickEvent clickEvent) { GWT.log ("Adding child"); canvasLayout.addChild (canvas); } }); // add a button that shows a dialog with a canvas with no opaticy set final IButton removeChildButton = new IButton (); removeChildButton.setTitle ("Remove Child"); removeChildButton.addClickHandler (new ClickHandler () { public void onClick (final ClickEvent clickEvent) { GWT.log ("Removing child"); canvasLayout.removeChild (canvas); } }); // add final VLayout mainLayout = new VLayout (); mainLayout.addMember (addChildButton); mainLayout.addMember (removeChildButton); mainLayout.addMember (canvasLayout); mainLayout.draw (); } }
Comment