diff options
2 files changed, 38 insertions, 4 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/widgets/Synchronizer.java b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/widgets/Synchronizer.java index 87916c0198..6c2f265c34 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/widgets/Synchronizer.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/widgets/Synchronizer.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2011 IBM Corporation and others. + * Copyright (c) 2000, 2014 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -138,7 +138,9 @@ boolean runAsyncMessages (boolean all) { lock.throwable = t; SWT.error (SWT.ERROR_FAILED_EXEC, t); } finally { - display.sendPostEvent(null); + if (display != null && !display.isDisposed()) { + display.sendPostEvent(null); + } syncThread = null; lock.notifyAll (); } @@ -184,7 +186,9 @@ protected void syncExec (Runnable runnable) { try { runnable.run(); } finally { - display.sendPostEvent(null); + if (display != null && !display.isDisposed()) { + display.sendPostEvent(null); + } } } return; diff --git a/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_widgets_Display.java b/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_widgets_Display.java index 8312bd7923..dfcceb6a63 100644 --- a/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_widgets_Display.java +++ b/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_widgets_Display.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2013 IBM Corporation and others. + * Copyright (c) 2000, 2014 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -131,6 +131,23 @@ public void test_asyncExecLjava_lang_Runnable() { } } +public void test_asyncExecLjava_lang_Runnable_dispose() { + final Display display = new Display(); + try { + disposeExecRan = false; + display.asyncExec(new Runnable() { + public void run() { + display.dispose(); + disposeExecRan = true; + } + }); + } finally { + while (!disposeExecRan) { + if (!display.readAndDispatch()) display.sleep (); + } + } +} + public void test_beep() { Display display = new Display(); try { @@ -990,6 +1007,19 @@ public void test_syncExecLjava_lang_Runnable() { } } +public void test_syncExecLjava_lang_Runnable_dispose() { + final Display display = new Display(); + try { + display.syncExec(new Runnable() { + public void run() { + display.dispose(); + } + }); + } finally { + assertTrue(display.isDisposed()); + } +} + public void test_timerExecILjava_lang_Runnable() { final Display display = new Display(); try { |