Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Unhandled event loop exception(MozillaDelegate throwing NPE on Linux)
Unhandled event loop exception [message #754205] Tue, 01 November 2011 11:25 Go to next message
Mark Fishman is currently offline Mark FishmanFriend
Messages: 27
Registered: March 2011
Junior Member
I am running into a problem with the browser component on linux. If I detach the view that has the browser, and then close it, I get a NullPointerException in MozillaDelegate. The exception occurs when I actually click the 'x' and appears in my workspace's .log file. My app is built using Eclipse 3.7.1 and this only happens on Linux.

The stack trace for the exception is:

! MESSAGE Unhandled event loop exception
! STACK 0
java.lang.NullPointerException
at org.eclipse.swt.browser.MozillaDelegate$1.handleEvent(MozillaDelegate.java:141)
at org.eclipse.swt.widgets.Event.Table.sendEvent(EventTable.java:84)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1258)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1282)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1263)
...

From a copy of the source code that I found online, it looks like the method that is causing the NPE, is the following in the MozillaDelegate:

135 void handleFocus () {
136 if (hasFocus) return;
137 hasFocus = true;
138 listener = new Listener () {
139 handleEvent (Event event) {
140 if (event.widget == browser) return;
141 ((Mozilla)browser.webBrowser).Deactivate ();
142 hasFocus = false;
143 browser.getDisplay ().removeFilter (SWT.FocusIn, this);
144 browser.getShell ().removeListener (SWT.Deactivate, this);
145 listener = null;
146 }
147 };
148 browser.getDisplay ().addFilter (SWT.FocusIn, listener);
149 browser.getShell ().addListener (SWT.Deactivate, listener);
150 }

Has anyone run into a similar problem? Are there any suggestions on ways to fix this?

One thought that I had had, since it looks like the issue is related to the browser still having focus when the dispose happens, was to make sure that I transferred the focus prior to the closing. However, I can't find any events that happen during the close that I could latch off of that occur before the widgets are disposed.

Any thoughts or suggestions would be greatly appreciated.

Thanks.
Re: Unhandled event loop exception [message #754820 is a reply to message #754205] Fri, 04 November 2011 13:29 Go to previous messageGo to next message
Mark Fishman is currently offline Mark FishmanFriend
Messages: 27
Registered: March 2011
Junior Member
OK. So I have a solution that appears to resolve this issue. It is an extreme hack though and I wanted to check to see if anyone can tell me if this is a really bad idea or not.

My solution was to add a control listener to the view that I used to detect when it is detached. When that happens, I run the following code:

if(Util.isLinux())
{
browser.getShell().addListener(SWT.Deactivate, new Listener()
{
public void handleEvent(Event evt)
{
// short circuit the event
event.type = SWT.None;
}
});
}


This appears to fix my problem and, after a bunch of testing, I don't think it causes any side effects like a memory leak.

Can anyone tell me a reason why this solution might be a bad idea?

Thanks.

-- Mark
Re: Unhandled event loop exception [message #755466 is a reply to message #754820] Tue, 08 November 2011 15:23 Go to previous message
Grant Gayed is currently offline Grant GayedFriend
Messages: 2151
Registered: July 2009
Senior Member
Hi Mark,

Firstly, I've logged a report for the problem you describe:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=363084 . A fix for it is
committed to the 3.8 stream, and it's also currently planned to add it
to the 3.7.2 stream for the release in February.

Regarding workarounds, if you want to know when a Browser is about to be
disposed (assuming you have a handle to it), you can add a listener like
"browser.addListener(SWT.Dispose, new Listener() {...})". If
transferring focus at dispose time works around the problem for you then
this sounds like a safer approach than adding the Deactivate listener on
the Shell. I don't have a specific reason to recommend against the
Deactivate approach, and if it's your only choice then it may be fine,
it just seems more intrusive in comparison.

Grant


On 11/4/2011 9:29 AM, mfishm1 wrote:
> OK. So I have a solution that appears to resolve this issue. It is an
> extreme hack though and I wanted to check to see if anyone can tell me
> if this is a really bad idea or not.
> My solution was to add a control listener to the view that I used to
> detect when it is detached. When that happens, I run the following code:
>
> if(Util.isLinux())
> {
> browser.getShell().addListener(SWT.Deactivate, new Listener()
> {
> public void handleEvent(Event evt)
> {
> // short circuit the event event.type = SWT.None;
> }
> });
> }
>
>
> This appears to fix my problem and, after a bunch of testing, I don't
> think it causes any side effects like a memory leak.
> Can anyone tell me a reason why this solution might be a bad idea?
>
> Thanks.
>
> -- Mark
Previous Topic:IE Browser issue: revocation information is not available
Next Topic:Suggested way to add double click behavior to table
Goto Forum:
  


Current Time: Mon Dec 22 02:49:17 GMT 2014

Powered by FUDForum. Page generated in 0.01944 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software