Community
Participate
Working Groups
The constructor of the attached class creates a display and a window. If we created just one thread creating one instance, everything is OK. If two threads are started, we get the following, even if display, shell and input event loop are all run by the same thread: org.eclipse.swt.SWTException: Invalid thread access at org.eclipse.swt.SWT.error(SWT.java:2691) at org.eclipse.swt.SWT.error(SWT.java:2616) at org.eclipse.swt.SWT.error(SWT.java:2587) at org.eclipse.swt.widgets.Display.error(Display.java:828) at org.eclipse.swt.widgets.Display.checkDevice(Display.java:575) at org.eclipse.swt.widgets.Display.getFocusControl(Display.java:1212) at org.eclipse.swt.widgets.Control.sendFocusEvent(Control.java:2263) at org.eclipse.swt.widgets.Control.gtk_event_after(Control.java:1747) at org.eclipse.swt.widgets.Widget.windowProc(Widget.java:1202) at org.eclipse.swt.widgets.Display.windowProc(Display.java:3098) at org.eclipse.swt.internal.gtk.OS.gtk_main_do_event(Native Method) at org.eclipse.swt.widgets.Display.eventProc(Display.java:879) at org.eclipse.swt.internal.gtk.OS.gtk_main_iteration(Native Method) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2297) at it.unimi.dsi.mat.lab.Bug.<init>(Bug.java:16) at it.unimi.dsi.mat.lab.Bug$1.run(Bug.java:25) org.eclipse.swt.SWTException: Invalid thread access at org.eclipse.swt.SWT.error(SWT.java:2691) at org.eclipse.swt.SWT.error(SWT.java:2616) at org.eclipse.swt.SWT.error(SWT.java:2587) at org.eclipse.swt.widgets.Widget.error(Widget.java:376) at org.eclipse.swt.widgets.Widget.checkWidget(Widget.java:313) at org.eclipse.swt.widgets.Control.getShell(Control.java:1627) at org.eclipse.swt.widgets.Control.getPath(Control.java:1596) at org.eclipse.swt.widgets.Shell.setActiveControl(Shell.java:915) at org.eclipse.swt.widgets.Control.sendFocusEvent(Control.java:2250) at org.eclipse.swt.widgets.Control.gtk_event_after(Control.java:1747) at org.eclipse.swt.widgets.Widget.windowProc(Widget.java:1202) at org.eclipse.swt.widgets.Display.windowProc(Display.java:3098) at org.eclipse.swt.internal.gtk.OS.gtk_main_do_event(Native Method) at org.eclipse.swt.widgets.Display.eventProc(Display.java:879) at org.eclipse.swt.internal.gtk.OS.gtk_main_iteration(Native Method) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2297) at it.unimi.dsi.mat.lab.Bug.<init>(Bug.java:16) at it.unimi.dsi.mat.lab.Bug$2.run(Bug.java:31) import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Shell; public class Bug { public Bug() { Display display = new Display(); Shell shell = new Shell( display ); shell.setSize( 50, 50 ); shell.open(); while ( ! shell.isDisposed() ) { if ( !display.readAndDispatch() ) { display.sleep(); } } } public static void main( String arg[] ) { new Thread() { public void run() { new Bug(); } }.start(); new Thread() { public void run() { new Bug(); } }.start(); } }
We discovered that, in fact, it is not guaranteed that it is possible to create two Display instances on all platform. The code we sent works perfectly on Windows, for instance. Nonetheless, the kind of error returned is completely misleading, and frustrating. Something like "Too many displays" or "You cannot create two displays in the *** implementation of SWT" would be definitely more appropriate...
SSQ and SN to give a better error message. I thought we threw an error when the display was created. SSQ?
I released changes that will cause an appropiate exception to be thrown on platforms were multiple displays is not supported yet.
We now give a better exception. Downgrading to an enhancement. We will not get to this for 3.1.
I had Eclipse 3.2M6 running for about 1 day on GTK using a dual-monitor configuration without any problem whatsoever (not being aware of this annoying limitation) and then, suddenly, after a routine restart of Eclipse (no change to my display configuration that I'm aware of), I hit this problem and there's no way to get Eclipse back up and running. I have tried downgrading my display so that it only uses one of the screens (although I have to admit I'm no huge expert in Linux/Gnome) but this doesn't sort me out. The stack trace in .log is as follows: org.eclipse.swt.SWTError: Not implemented [multiple displays] at org.eclipse.swt.SWT.error(SWT.java:3400) at org.eclipse.swt.widgets.Display.checkDisplay(Display.java:662) at org.eclipse.swt.widgets.Display.create(Display.java:775) at org.eclipse.swt.graphics.Device.<init>(Device.java:145) at org.eclipse.swt.widgets.Display.<init>(Display.java:452) at org.eclipse.swt.widgets.Display.<init>(Display.java:443) at org.eclipse.ui.internal.Workbench.createDisplay(Workbench.java:448) at org.eclipse.ui.PlatformUI.createDisplay(PlatformUI.java:155) My OS is Red Hat 3.4.4-2 (kernel 2.6.9-22.0.1.ELsmp) and X is v6.8.2 I think this bug definitely deserves some attention. I work at a large US investment bank and I was about to suggest that we could move our development from Windows to Linux... not anymore.
Mutiple displays does not refer to dual monitors. Multiple displays mean that you can have multiple SWT Display objects and multiple SWT event loops in the same process. Can you provide some code that shows the problem?
If you are seeing Eclipse crash in that way, please file a new bug against Platform UI. It is likely a bug in some plugin you are using and not related to this feature request.
(In reply to comment #6 & #7) You are both right: the problem's got nothing to do with multiple monitors and it is indeed caused by a rogue plugin (none else than IBM's ClearCase plugin, courtesy of http://www-128.ibm.com/developerworks/rational/library/content/03July/2500/2834/ClearCase/clearcase_plugins.html) in its latest incarnation, dated 20060127. I have found out that if I don't get the plugin to "connect automatically to ClearCase on startup", the problem no longer occurs (to be fair, the plugin is not officially supported on 3.2). I gather this is therefore not an Eclipse bug. Thanks for all your very diligent help! Christian
Ok, thanks for following up and letting us know what happened. The Clear Case plugin seems to be creating multiple Displays which is not supported on GTK or the Mac. There are already bug reports that are tracking these issues.
The Polarion Subversive subversion plugin also seems to be doing this when I right click on the project for some reason, too.