diff options
author | Johannes Dahlström <johannes.dahlstrom@vaadin.com> | 2013-05-08 10:49:20 +0000 |
---|---|---|
committer | Vaadin Code Review <review@vaadin.com> | 2013-05-13 14:03:40 +0000 |
commit | 29eeda592cf0f219582f1ccc9320457ca630a28e (patch) | |
tree | cea87e6f99f322cdae45ba63c183abcb6b5f2d69 /client | |
parent | 936439dfe4be81637e63f539e281e190c1155460 (diff) | |
download | vaadin-framework-29eeda592cf0f219582f1ccc9320457ca630a28e.tar.gz vaadin-framework-29eeda592cf0f219582f1ccc9320457ca630a28e.zip |
Merge "Clean up Table popup menu close handler to prevent a memory leak" from 6.8 (#11840)
svn changeset:25919/svn branch:6.8
Change-Id: If0b414588252226947230cf2f7a5a8ab253cc5d7
Diffstat (limited to 'client')
-rw-r--r-- | client/src/com/vaadin/client/ui/VScrollTable.java | 31 | ||||
-rw-r--r-- | client/src/com/vaadin/client/ui/table/TableConnector.java | 5 |
2 files changed, 25 insertions, 11 deletions
diff --git a/client/src/com/vaadin/client/ui/VScrollTable.java b/client/src/com/vaadin/client/ui/VScrollTable.java index b03fa945cd..8705a826cc 100644 --- a/client/src/com/vaadin/client/ui/VScrollTable.java +++ b/client/src/com/vaadin/client/ui/VScrollTable.java @@ -60,6 +60,7 @@ import com.google.gwt.event.dom.client.ScrollEvent; import com.google.gwt.event.dom.client.ScrollHandler; import com.google.gwt.event.logical.shared.CloseEvent; import com.google.gwt.event.logical.shared.CloseHandler; +import com.google.gwt.event.shared.HandlerRegistration; import com.google.gwt.user.client.Command; import com.google.gwt.user.client.DOM; import com.google.gwt.user.client.Element; @@ -556,15 +557,24 @@ public class VScrollTable extends FlowPanel implements HasWidgets, * <p> * For internal use only. May be removed or replaced in the future. */ - public class ContextMenuDetails { + public class ContextMenuDetails implements CloseHandler<PopupPanel> { public String rowKey; public int left; public int top; + HandlerRegistration closeRegistration; - public ContextMenuDetails(String rowKey, int left, int top) { + public ContextMenuDetails(VContextMenu menu, String rowKey, int left, + int top) { this.rowKey = rowKey; this.left = left; this.top = top; + this.closeRegistration = menu.addCloseHandler(this); + } + + @Override + public void onClose(CloseEvent<PopupPanel> event) { + contextMenu = null; + closeRegistration.removeHandler(); } } @@ -6021,15 +6031,20 @@ public class VScrollTable extends FlowPanel implements HasWidgets, public void showContextMenu(Event event) { if (enabled && actionKeys != null) { // Show context menu if there are registered action handlers - int left = Util.getTouchOrMouseClientX(event); - int top = Util.getTouchOrMouseClientY(event); - top += Window.getScrollTop(); - left += Window.getScrollLeft(); - contextMenu = new ContextMenuDetails(getKey(), left, top); - client.getContextMenu().showAt(this, left, top); + int left = Util.getTouchOrMouseClientX(event) + + Window.getScrollLeft(); + int top = Util.getTouchOrMouseClientY(event) + + Window.getScrollTop(); + showContextMenu(left, top); } } + public void showContextMenu(int left, int top) { + VContextMenu menu = client.getContextMenu(); + contextMenu = new ContextMenuDetails(menu, getKey(), left, top); + menu.showAt(this, left, top); + } + /** * Has the row been selected? * diff --git a/client/src/com/vaadin/client/ui/table/TableConnector.java b/client/src/com/vaadin/client/ui/table/TableConnector.java index fc31cdf8ea..6e50bab9ab 100644 --- a/client/src/com/vaadin/client/ui/table/TableConnector.java +++ b/client/src/com/vaadin/client/ui/table/TableConnector.java @@ -364,9 +364,8 @@ public class TableConnector extends AbstractHasComponentsConnector implements Widget w = iterator.next(); VScrollTableRow row = (VScrollTableRow) w; if (row.getKey().equals(savedContextMenu.rowKey)) { - getWidget().contextMenu = savedContextMenu; - getConnection().getContextMenu().showAt(row, - savedContextMenu.left, savedContextMenu.top); + row.showContextMenu(savedContextMenu.left, + savedContextMenu.top); } } } |