Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 286065

Summary: [Browser] Nested modal dialogs with browser components fail to open
Product: [Eclipse Project] Platform Reporter: Zviki Cohen <zvikico>
Component: SWTAssignee: Platform-SWT-Inbox <platform-swt-inbox>
Status: CLOSED WORKSFORME QA Contact: Grant Gayed <grant_gayed>
Severity: normal    
Priority: P3 CC: ericwill, pinnamur, Silenio_Quarti
Version: 3.5Keywords: triaged
Target Milestone: ---   
Hardware: All   
OS: Linux-GTK   
Whiteboard:

Description Zviki Cohen CLA 2009-08-09 08:11:17 EDT
Here's the scenario: 
1. Create a modal dialog that uses a browser component - I used a JFace dialog, but see the example below for a simpler case. 
2. From a browser event (could happen in other cases as well), open a nested dialog box with another browser component.
On Linux, this browser will not be rendered due to issues with the event loop handling. 

In the code snippet below, removing the event look for shell 2 will eliminate this issue. 
When using Windows (or JFace dialogs), one needs to use setBlockOnOpen(false) to make the nested dialog open properly. Still, this means the second dialog is not really modal, so this is not a very good solution (one might play with focus, but we are missing the point here). 

Note: this works just fine on Windows and OS X. Tested on various versions of Ubuntu (GTK).

import org.eclipse.swt.SWT;
import org.eclipse.swt.browser.Browser;
import org.eclipse.swt.browser.LocationEvent;
import org.eclipse.swt.browser.LocationListener;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;

public class Snippet {

	public static void main(String[] args) {
		final Display display = new Display();
		final Shell shell = new Shell(display);
		shell.setText("This is the main shell");
		Browser browser = new Browser(shell, SWT.NONE);
		browser.setBounds(10, 10, 200, 100);
		browser
				.setText("<html><body><A HREF=\"www\">click me</a></body></html>");

		browser.addLocationListener(new LocationListener() {

			public void changing(LocationEvent arg0) {
				arg0.doit = false;
				Shell shell2 = new Shell(display);
				shell2.setText("This is the nested shell");
				Browser browser = new Browser(shell2, SWT.NONE);
				browser.setBounds(10, 10, 100, 200);
				browser
						.setText("<html><body><p>You can't see me on Linux</p></body></html>");
				shell2.open();
				// This is the source of the issue !
				while (!shell2.isDisposed())
				if (!display.readAndDispatch())
					display.sleep();
				display.dispose();
				
			}
			
			public void changed(LocationEvent arg0) {

			}
		});

		shell.open();
		while (!shell.isDisposed())
			if (!display.readAndDispatch())
				display.sleep();
		display.dispose();
	}

}
Comment 1 Eric Williams CLA 2019-01-18 11:56:29 EST
I can't reproduce the issue on GTK3.24.3, SWT from master as of this morning, and Fedora 29 (WebKit 2). Please reopen this ticket if the issue persists.