Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 93294 - Support multiple Displays on GTK
Summary: Support multiple Displays on GTK
Status: RESOLVED INVALID
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 3.1   Edit
Hardware: PC Linux-GTK
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: Silenio Quarti CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-04-29 12:46 EDT by Sebastiano Vigna CLA
Modified: 2007-03-02 16:39 EST (History)
6 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Sebastiano Vigna CLA 2005-04-29 12:46:11 EDT
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();
	}
}
Comment 1 Sebastiano Vigna CLA 2005-05-02 10:43:46 EDT
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...
Comment 2 Steve Northover CLA 2005-05-02 10:50:51 EDT
SSQ and SN to give a better error message.  I thought we threw an error when 
the display was created.  SSQ?
Comment 3 Silenio Quarti CLA 2005-05-02 16:44:15 EDT
I released changes that will cause an appropiate exception to be thrown on 
platforms were multiple displays is not supported yet.
Comment 4 Steve Northover CLA 2005-05-24 10:55:54 EDT
We now give a better exception.  Downgrading to an enhancement.  We will not 
get to this for 3.1.
Comment 5 Christian Sarrasin CLA 2006-04-07 15:32:09 EDT
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.
Comment 6 Steve Northover CLA 2006-04-07 15:57:02 EDT
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?
Comment 7 Billy Biggs CLA 2006-04-08 00:27:35 EDT
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.
Comment 8 Christian Sarrasin CLA 2006-04-11 04:06:49 EDT
(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
Comment 9 Steve Northover CLA 2006-04-11 11:04:44 EDT
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.
Comment 10 Michael R. Head CLA 2007-03-02 16:39:06 EST
The Polarion Subversive subversion plugin also seems to be doing this when I right click on the project for some reason, too.