aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNiraj Modi2014-02-12 07:52:38 (EST)
committerGerrit Code Review @ Eclipse.org2014-02-20 06:55:26 (EST)
commit1044cdb75e07ed6f780309c62b725a61a433f65c (patch)
tree452b909bc6d541c0a6fb2277099b0ba36568a7fc
parent33029c31f19c5fff9776631a726a1e53e26b649f (diff)
downloadeclipse.platform.swt-1044cdb75e07ed6f780309c62b725a61a433f65c.zip
eclipse.platform.swt-1044cdb75e07ed6f780309c62b725a61a433f65c.tar.gz
eclipse.platform.swt-1044cdb75e07ed6f780309c62b725a61a433f65c.tar.bz2
Bug 426172 - Possible NullpointerException on Display.runAsyncMessagesrefs/changes/57/21657/3
Change-Id: I1d8543ff454184d0ea20a87c29e647bb6f9368c5 Signed-off-by: Niraj Modi <niraj.modi@in.ibm.com>
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/widgets/Synchronizer.java10
-rw-r--r--tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_widgets_Display.java32
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 87916c0..6c2f265 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 8312bd7..dfcceb6 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 {