Matthew Dempsky has submitted this change and it was merged.
Change subject: Fix module unloading with multiple modules on a page
......................................................................
Fix module unloading with multiple modules on a page
Currently, the GWT compiler in production compiles will optimize away
the instanceof checks in isMyListener() because it assumes
getEventListener() is actually returning an EventListener object.
However, if there are multiple modules loaded on a page, the
__listener property might be for an EventListener from a different
module.
One way to workaround this (the approach taken by this patch) is to
call isMyListener() before getEventListener() returns, so the compiler
can't optimize away the instanceof checks.
Change-Id: I25d9471c1e14756196a11223eadb765ed303a3b4
---
M user/src/com/google/gwt/user/client/impl/DOMImpl.java
1 file changed, 5 insertions(+), 6 deletions(-)
Approvals:
Ray Cromwell: Looks good to me, approved
Leeroy Jenkins: Verified
Thomas Broyer: Looks good to me, but someone else must approve
diff --git a/user/src/com/google/gwt/user/client/impl/DOMImpl.java
b/user/src/com/google/gwt/user/client/impl/DOMImpl.java
index c5b8187..eafd332 100644
--- a/user/src/com/google/gwt/user/client/impl/DOMImpl.java
+++ b/user/src/com/google/gwt/user/client/impl/DOMImpl.java
@@ -50,12 +50,9 @@
for (int i = 0; i < allElements.getLength(); i++) {
com.google.gwt.dom.client.Element elem = allElements.getItem(i);
Element userElem = (Element) elem;
- if (dom.getEventsSunk(userElem) != 0) {
- dom.sinkEvents(userElem, 0);
- }
EventListener listener = dom.getEventListener(userElem);
- // nulls out event listener if and only if it was assigned from our
module
- if (GWT.isScript() && listener != null && isMyListener(listener)) {
+ if (GWT.isScript() && listener != null) {
+ dom.sinkEvents(userElem, 0);
dom.setEventListener(userElem, null);
}
// cleans up DOM-style addEventListener registered handlers
@@ -154,7 +151,9 @@
public abstract int getChildIndex(Element parent, Element child);
public native EventListener getEventListener(Element elem) /*-{
- return elem.__listener;
+ // Return elem.__listener if and only if it was assigned from our
module
+ var maybeListener = elem.__listener;
+ return
@com.google.gwt.user.client.impl.DOMImpl::isMyListener(Ljava/lang/Object;)(maybeListener) ?
maybeListener : null;
}-*/;
public native int getEventsSunk(Element elem) /*-{
--
To view, visit https://gwt-review.googlesource.com/2941
To unsubscribe, visit https://gwt-review.googlesource.com/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I25d9471c1e14756196a11223eadb765ed303a3b4
Gerrit-PatchSet: 1
Gerrit-Project: gwt
Gerrit-Branch: master
Gerrit-Owner: Matthew Dempsky <[email protected]>
Gerrit-Reviewer: Leeroy Jenkins <[email protected]>
Gerrit-Reviewer: Matthew Dempsky <[email protected]>
Gerrit-Reviewer: Ray Cromwell <[email protected]>
Gerrit-Reviewer: Thomas Broyer <[email protected]>
--
http://groups.google.com/group/Google-Web-Toolkit-Contributors
---
You received this message because you are subscribed to the Google Groups "GWT Contributors" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.