void doLogicalClear() { if (orphanCommand == null) { orphanCommand = new AttachDetachException.Command() { public void execute(Widget w) { orphan(w); } }; } try { AttachDetachException.tryCommand(this, orphanCommand); } finally { children = new WidgetCollection(this); } }
private static void detachWidgets() { // When the window is closing, detach all widgets that need to be // cleaned up. This will cause all of their event listeners // to be unhooked, which will avoid potential memory leaks. try { AttachDetachException.tryCommand(widgetsToDetach, maybeDetachCommand); } finally { widgetsToDetach.clear(); } }