Bug 286065 - [Browser] Nested modal dialogs with browser components fail to open
Summary: [Browser] Nested modal dialogs with browser components fail to open
Status: CLOSED WORKSFORME
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 3.5   Edit
Hardware: All Linux-GTK
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Platform-SWT-Inbox CLA
QA Contact: Grant Gayed CLA
URL:
Whiteboard:
Keywords: triaged
Depends on:
Blocks:
 
Reported: 2009-08-09 08:11 EDT by Zviki Cohen CLA
Modified: 2019-01-18 11:56 EST (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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.