Deregister all widgets before resetting a table's HTML
This way we give the widgets a chance to fire their onUnload method
and possibly perform state saving actions during the unload event.
Signed-off-by: Shawn O. Pearce <sop@google.com>
diff --git a/webapp/src/com/google/gerrit/client/ui/FancyFlexTable.java b/webapp/src/com/google/gerrit/client/ui/FancyFlexTable.java
index 34a0f00..7a5b0e2 100644
--- a/webapp/src/com/google/gerrit/client/ui/FancyFlexTable.java
+++ b/webapp/src/com/google/gerrit/client/ui/FancyFlexTable.java
@@ -30,6 +30,7 @@
import com.google.gwt.user.client.ui.KeyboardListenerAdapter;
import com.google.gwt.user.client.ui.Widget;
+import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.Map.Entry;
@@ -98,6 +99,10 @@
}
protected void resetHtml(final String body) {
+ for (final Iterator<Widget> i = table.iterator(); i.hasNext();) {
+ i.next();
+ i.remove();
+ }
DOM.setInnerHTML(table.getBodyElement(), body);
}