Bug 341538 - Setting GTK Look and Feel causes window to freeze when closed.
Summary: Setting GTK Look and Feel causes window to freeze when closed.
Status: RESOLVED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 4.1   Edit
Hardware: PC Linux
: P3 critical (vote)
Target Milestone: ---   Edit
Assignee: Silenio Quarti CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-03-31 15:33 EDT by Ken Keefe CLA
Modified: 2015-08-11 14:21 EDT (History)
4 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ken Keefe CLA 2011-03-31 15:33:36 EDT
Build Identifier: M20110210-1200

I'm using Ubuntu 10.04 64-bit. I've tested my application on Windows and OSX and it is not experiencing a similar problem.

I'm developing an RCP application that uses SWING components (for legacy reasons). I just recently came across this problem, but I'm not sure if it is new. When I set the look and feel for SWING using: 

try {
	UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch (Exception e) {
	System.out.println(e);
}

And run my application, it behaves normally. But when I click the X button in the corner of my main window, the application just freezes. I can't seem to get any sort of debugging information on this error, it just freezes until the window manager asks if it should be killed.

Also, if I set the look and feel to something other than the GTK one (for example, motif), this problem does not occur. Only when the GTK LaF is used.

Finally, I tried to see if I could reproduce this problem using only SWT with the following code and the problem did NOT occur. I was able to reproduce the problem in a simple test case that I describe in the Steps to Reproduce.

import javax.swing.UIManager;

import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;

public class Main {
	public static void main(String[] args) {
		try {
			UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
		} catch (Exception e) {
			System.out.println(e);
		}
		Display display = new Display();
		Shell shell = new Shell(display);

		shell.setText("Hello, world!");

		shell.open();

		// Set up the event loop.
		while (!shell.isDisposed()) {
			if (!display.readAndDispatch()) {
				// If no more entries in event queue
				display.sleep();
			}
		}

		display.dispose();
	}
}




Reproducible: Always

Steps to Reproduce:
1. Create a new RCP application and use the Hello World template.
2. Do either 2a OR 2b.
2a. Add this code to the beginning of the Application.start method:
try {
	UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch (Exception e) {
	System.out.println(e);
}
// Template code below...
	Display display....
2b. In the run configuration, add this to the VM Arguments: -Dswing.defaultlaf=com.sun.java.swing.plaf.gtk.GTKLookAndFeel
3. Run the Hello World application.
4. Click the X button in the corner of the window and it should be frozen now.
Comment 1 Remy Suen CLA 2011-03-31 16:05:39 EDT
May be related to bug 320524.
Comment 2 Silenio Quarti CLA 2011-04-06 11:33:40 EDT
Do you open a MessageBox (or some other dialog) when exiting your RCP app? If so, this i a dup of bug#280649.
Comment 3 Ken Keefe CLA 2011-04-06 11:41:56 EDT
No, I don't think this is a duplicate. Take a look at the steps to reproduce this bug. It uses only the code from the Hello World RCP template and this call:

UIManager.getSystemLookAndFeelClassName()

I think this must be a problem with GTK and the RCP code. I was unable to reproduce this bug using just SWT.
Comment 4 Ken Keefe CLA 2011-04-06 11:42:46 EDT
Sorry, this is the call I should have pasted:

UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
Comment 5 Silenio Quarti CLA 2011-04-07 10:53:56 EDT
Yes, this is a slightly different manifestion of bug#280649. The root cause of this problem is the fact that AWT/Swing is initializing GTK threads (gdk_threads_init()) when the GTK L&F is used.  I released a workaround that avoids this deadlock as well, but the complete solution requires changes in both toolkits (see bug#341799).

Fixed > 20110407.
Comment 6 Ken Keefe CLA 2011-04-07 11:35:34 EDT
(In reply to comment #5)
> Yes, this is a slightly different manifestion of bug#280649. The root cause of
> this problem is the fact that AWT/Swing is initializing GTK threads
> (gdk_threads_init()) when the GTK L&F is used.  I released a workaround that
> avoids this deadlock as well, but the complete solution requires changes in
> both toolkits (see bug#341799).
> 
> Fixed > 20110407.

Is the workaround described in bug#280649 (I can't seem to access this bug), bug#341799, or somewhere else? Thanks very much for letting me know what the problem is.
Comment 7 Silenio Quarti CLA 2011-04-07 11:46:56 EDT
The workaround for this bug is to call gdk_threads_leave() before SWT calls g_main_context_iteration() in Display.readAndDispatch().
Comment 8 Silenio Quarti CLA 2011-04-07 11:56:13 EDT
You should be able to see bug#280649 now.
Comment 9 Stefan Xenos CLA 2015-08-11 14:21:05 EDT
This bug appears to have been the cause of bug 354842.