Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Embedding SWT Browser in Equinox launched Swing App on MacOS
Embedding SWT Browser in Equinox launched Swing App on MacOS [message #965772] Wed, 31 October 2012 13:42 Go to next message
Dan Pollitt is currently offline Dan PollittFriend
Messages: 55
Registered: August 2010
Member
Hi all,

I have a large Swing application that runs ontop of Eclipse and is
started using the eclipse org.eclipse.core.runtime.applications
extension point.

In several places within the application we embed an SWT Browser
component within the Swing app using org.eclipse.swt.awt.SWT_AWT. We
maintain a single org.eclipse.swt.widgets.Display object that is created
in a new Thread (not the main(..) thread as we don't have access to
that), with that same thread being used to execute the readAndDispatch()
loop.

The app works as desired on Windows however we see the following when
Running on MacOS:

***WARNING: Display must be created on main thread due to Cocoa
restrictions.
Exception in thread "BrowserPanel SWT Thread"
org.eclipse.swt.SWTException: Invalid thread access
at org.eclipse.swt.SWT.error(SWT.java:4083)
at org.eclipse.swt.SWT.error(SWT.java:3998)
at org.eclipse.swt.SWT.error(SWT.java:3969)
at org.eclipse.swt.widgets.Display.error(Display.java:1030)
at org.eclipse.swt.widgets.Display.createDisplay(Display.java:797)
at org.eclipse.swt.widgets.Display.create(Display.java:780)
at org.eclipse.swt.graphics.Device.<init>(Device.java:130)
at org.eclipse.swt.widgets.Display.<init>(Display.java:671)
at org.eclipse.swt.widgets.Display.<init>(Display.java:662)



Versions of relevant things:

SWT
org.eclipse.swt_3.6.3.v3659f and
org.eclipse.swt.cocoa.macosx.x86_64_3.6.3.v3659f

MacOS
OS X Version 10.8.2

Java
java.version=1.6.0_37
java.vendor=Apple Inc.
BootLoader constants: OS=macosx, ARCH=x86_64, WS=cocoa, NL=en_US


After doing some searching online I am confused as to how I should
address this (there seem to have been various SWT_AWT issues on MacOS
that have been resolved by different teams over the last 5 years or so).
I have seen reference to use of the -XstartOnFirstThread flag however
I'm not sure whether this is:

a) Still relevant
b) Appropriate, being that this is embedding SWT within Swing (as
opposed to the other way round) and that the app doesn't control the
main thread.


Can someone help me understand the state of the world regarding this
issue as of the MacOS/SWT/Java versions I'm using and ideally point me
in the right direction to resolve?


Many thanks,
Dan
Re: Embedding SWT Browser in Equinox launched Swing App on MacOS [message #968272 is a reply to message #965772] Fri, 02 November 2012 10:29 Go to previous message
Eclipse UserFriend
I believe that on MacOS X, SWT *must* be the main thread. I think it will work providing you run with -XstartOnFirstThread and ensure your app first creates an SWT Diplay before doing any Swing/AWT operations (e.g., in IApplication#start()).
Previous Topic:How to disable text in a multi-line text box
Next Topic:Windows Meta File (WMF) support
Goto Forum:
  


Current Time: Tue Apr 23 15:58:19 GMT 2024

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

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

Back to the top