* Widget associated with the element, this method returns null.\r
*/\r
protected static Widget getAssociatedWidget(Element e) {\r
- EventListener listener = DOM.getEventListener((com.google.gwt.user.client.Element) e);\r
- // No listener attached to the element, so no widget exist for this element\r
- if (listener == null) {\r
- return null;\r
- }\r
- if (listener instanceof Widget) {\r
- // GWT uses the widget as event listener\r
- return (Widget) listener;\r
- } else if (listener instanceof EventsListener) {\r
- // GQuery replaces the gwt event listener and save it\r
- EventsListener gQueryListener = (EventsListener) listener;\r
- if (gQueryListener.getOriginalEventListener() != null\r
- && gQueryListener.getOriginalEventListener() instanceof Widget) {\r
- return (Widget) gQueryListener.getOriginalEventListener();\r
+ try {\r
+ EventListener listener = DOM.getEventListener((com.google.gwt.user.client.Element) e);\r
+ // No listener attached to the element, so no widget exist for this element\r
+ if (listener == null) {\r
+ return null;\r
}\r
+ if (listener instanceof Widget) {\r
+ // GWT uses the widget as event listener\r
+ return (Widget) listener;\r
+ } else if (listener instanceof EventsListener) {\r
+ // GQuery replaces the gwt event listener and save it\r
+ EventsListener gQueryListener = (EventsListener) listener;\r
+ if (gQueryListener.getOriginalEventListener() != null\r
+ && gQueryListener.getOriginalEventListener() instanceof Widget) {\r
+ return (Widget) gQueryListener.getOriginalEventListener();\r
+ }\r
+ }\r
+ } catch (Exception e2) {\r
+ // Some times this code could raise an exception. \r
+ // We do not want GQuery to fail, but in dev-move we log the error.\r
+ e2.printStackTrace();\r
}\r
return null;\r
}\r
\r
private void cleanGQData(Element... elements) {\r
for (Element el : elements) {\r
- EventsListener.clean(el);\r
- removeData(el, null);\r
+ try {\r
+ EventsListener.clean(el);\r
+ removeData(el, null);\r
+ } catch (Exception e) {\r
+ // If for some reason event/data removal fails, do not break the app,\r
+ // just log the error in dev-mode\r
+ // e.g.: this happens when removing iframes which are no fully loaded.\r
+ e.printStackTrace();\r
+ }\r
}\r
}\r
\r