View | Details | Raw Unified | Return to bug 564911
Collapse All | Expand All

(-)a/bundles/org.eclipse.swt/Eclipse SWT WebKit/gtk/org/eclipse/swt/browser/WebKit.java (-2 / +12 lines)
Lines 1891-1903 Link Here
1891
	 * You should check 'retObj.swtAsyncTimeout' after making a call to this.
1891
	 * You should check 'retObj.swtAsyncTimeout' after making a call to this.
1892
	 */
1892
	 */
1893
	private static Webkit2AsyncReturnObj execAsyncAndWaitForReturn(Browser browser, Consumer<Integer> asyncFunc, String additionalErrorInfo) {
1893
	private static Webkit2AsyncReturnObj execAsyncAndWaitForReturn(Browser browser, Consumer<Integer> asyncFunc, String additionalErrorInfo) {
1894
		class CtxIteration implements Runnable {
1895
			boolean eventsDispatched;
1896
1897
			@Override
1898
			public void run() {
1899
				eventsDispatched = OS.g_main_context_iteration (0, false);
1900
			}
1901
		}
1902
1894
		Webkit2AsyncReturnObj retObj = new Webkit2AsyncReturnObj();
1903
		Webkit2AsyncReturnObj retObj = new Webkit2AsyncReturnObj();
1895
		int callbackId = CallBackMap.putObject(retObj);
1904
		int callbackId = CallBackMap.putObject(retObj);
1896
		asyncFunc.accept(callbackId);
1905
		asyncFunc.accept(callbackId);
1897
		Display display = browser.getDisplay();
1906
		Display display = browser.getDisplay();
1898
		final Instant timeOut = Instant.now().plusMillis(ASYNC_EXEC_TIMEOUT_MS);
1907
		final Instant timeOut = Instant.now().plusMillis(ASYNC_EXEC_TIMEOUT_MS);
1899
		while (!browser.isDisposed()) {
1908
		while (!browser.isDisposed()) {
1900
			boolean eventsDispatched = OS.g_main_context_iteration (0, false);
1909
			CtxIteration ctxIteration = new CtxIteration();
1910
			display.asyncExec(ctxIteration);
1901
			if (retObj.callbackFinished)
1911
			if (retObj.callbackFinished)
1902
				break;
1912
				break;
1903
			else if (Instant.now().isAfter(timeOut)) {
1913
			else if (Instant.now().isAfter(timeOut)) {
Lines 1916-1922 Link Here
1916
				retObj.swtAsyncTimeout = true;
1926
				retObj.swtAsyncTimeout = true;
1917
				break;
1927
				break;
1918
			}
1928
			}
1919
			else if (!eventsDispatched)
1929
			else if (!ctxIteration.eventsDispatched)
1920
				display.sleep();
1930
				display.sleep();
1921
		}
1931
		}
1922
		CallBackMap.removeObject(callbackId);
1932
		CallBackMap.removeObject(callbackId);

Return to bug 564911