diff --git a/bundles/org.eclipse.swt/Eclipse SWT Browser/win32/org/eclipse/swt/browser/Edge.java b/bundles/org.eclipse.swt/Eclipse SWT Browser/win32/org/eclipse/swt/browser/Edge.java index b35a2f0b8b9..477726227bf 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT Browser/win32/org/eclipse/swt/browser/Edge.java +++ b/bundles/org.eclipse.swt/Eclipse SWT Browser/win32/org/eclipse/swt/browser/Edge.java @@ -221,10 +221,12 @@ static int callAndWait(long[] ppv, ToIntFunction callable) { }); ppv[0] = 0; phr[0] = callable.applyAsInt(completion); - completion.Release(); + // "completion" callback may be called asynchronously, + // so keep processing next OS message that may call it while (phr[0] == COM.S_OK && ppv[0] == 0) { processNextOSMessage(); } + completion.Release(); return phr[0]; } @@ -239,10 +241,12 @@ static int callAndWait(String[] pstr, ToIntFunction callable) { }); pstr[0] = null; phr[0] = callable.applyAsInt(completion); - completion.Release(); + // "completion" callback may be called asynchronously, + // so keep processing next OS message that may call it while (phr[0] == COM.S_OK && pstr[0] == null) { processNextOSMessage(); } + completion.Release(); return phr[0]; } diff --git a/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_browser_Browser.java b/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_browser_Browser.java index bef7f7e5cb7..6b501d2fdfc 100644 --- a/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_browser_Browser.java +++ b/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_browser_Browser.java @@ -280,6 +280,20 @@ public void test_Constructor_asyncParentDisposal() { assertFalse(browser.isDisposed()); } +@Test +public void test_Constructor_multipleInstantiationsInDifferentShells() { + final int numberOfBrowsers = 5; + for (int i = 0; i < numberOfBrowsers; i++) { + Shell browserShell = new Shell(Display.getCurrent()); + Browser browser = createBrowser(browserShell, SWT.EDGE); + assertFalse(browser.isDisposed()); + browser.dispose(); + assertTrue(browser.isDisposed()); + browserShell.dispose(); + assertTrue(browserShell.isDisposed()); + } +} + @Test public void test_evalute_Cookies () { final AtomicBoolean loaded = new AtomicBoolean(false);