Matthew Dempsky has uploaded a new change for review.

  https://gwt-review.googlesource.com/2941


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(-)



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: newchange
Gerrit-Change-Id: I25d9471c1e14756196a11223eadb765ed303a3b4
Gerrit-PatchSet: 1
Gerrit-Project: gwt
Gerrit-Branch: master
Gerrit-Owner: Matthew Dempsky <[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.


Reply via email to