aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRüdiger Herrmann2013-02-05 16:10:16 (EST)
committerPaul Webster2013-02-05 16:10:16 (EST)
commite99e241e00e118c5a949b684e638b1abb6949e63 (patch)
treef042db017457dce73022250265c2866a713432ef
parente090c714b97e644ac953b9d86f00cc0c5cfecc32 (diff)
downloadeclipse.platform.ui-e99e241e00e118c5a949b684e638b1abb6949e63.zip
eclipse.platform.ui-e99e241e00e118c5a949b684e638b1abb6949e63.tar.gz
eclipse.platform.ui-e99e241e00e118c5a949b684e638b1abb6949e63.tar.bz2
Bug 395890 - TreeColumnLayout$TreeLayoutListener doesn't check for
disposal Add dispose check and test.
-rw-r--r--bundles/org.eclipse.jface/src/org/eclipse/jface/layout/TreeColumnLayout.java9
-rw-r--r--tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/layout/AllTests.java3
-rw-r--r--tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/layout/TreeColumnLayoutTest.java57
3 files changed, 65 insertions, 4 deletions
diff --git a/bundles/org.eclipse.jface/src/org/eclipse/jface/layout/TreeColumnLayout.java b/bundles/org.eclipse.jface/src/org/eclipse/jface/layout/TreeColumnLayout.java
index 6bd55fd..d6af43e 100644
--- a/bundles/org.eclipse.jface/src/org/eclipse/jface/layout/TreeColumnLayout.java
+++ b/bundles/org.eclipse.jface/src/org/eclipse/jface/layout/TreeColumnLayout.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2009 IBM Corporation and others.
+ * Copyright (c) 2007, 2013 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
@@ -8,6 +8,7 @@
* Contributors:
* Tom Schindl <tom.schindl@bestsolution.at> - initial API and implementation
* - fix for bug 178280, 183999, 184609
+ * Ruediger Herrmann <ruediger.herrmann@gmx.de> - fix for bug 395890
* IBM Corporation - API refactoring and general maintenance
*******************************************************************************/
@@ -54,8 +55,10 @@ public class TreeColumnLayout extends AbstractColumnLayout {
tree.getDisplay().asyncExec(new Runnable() {
public void run() {
- tree.update();
- tree.getParent().layout();
+ if (!tree.isDisposed()) {
+ tree.update();
+ tree.getParent().layout();
+ }
}
});
diff --git a/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/layout/AllTests.java b/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/layout/AllTests.java
index 67c0292..dde1a0c 100644
--- a/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/layout/AllTests.java
+++ b/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/layout/AllTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006, 2008 IBM Corporation and others.
+ * Copyright (c) 2006, 2013 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
@@ -26,5 +26,6 @@ public class AllTests extends TestSuite {
public AllTests() {
addTestSuite(GeometryTest.class);
addTestSuite(AbstractColumnLayoutTest.class);
+ addTestSuite(TreeColumnLayoutTest.class);
}
}
diff --git a/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/layout/TreeColumnLayoutTest.java b/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/layout/TreeColumnLayoutTest.java
new file mode 100644
index 0000000..2be3b07
--- /dev/null
+++ b/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/layout/TreeColumnLayoutTest.java
@@ -0,0 +1,57 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Rüdiger Herrmann 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Rüdiger Herrmann - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jface.tests.layout;
+
+import junit.framework.TestCase;
+
+import org.eclipse.jface.layout.TreeColumnLayout;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Tree;
+
+public class TreeColumnLayoutTest extends TestCase {
+
+ private Display display;
+ private Shell parent;
+
+ public void testBug395890LayoutAfterExpandEventWithDisposedTree() throws Exception {
+ Tree tree = new Tree(parent, SWT.NONE);
+ TreeColumnLayout layout = new TreeColumnLayout();
+ parent.setLayout(layout);
+ parent.layout(true, true);
+ tree.notifyListeners(SWT.Expand, null);
+ tree.dispose();
+ try {
+ flushPendingEvents();
+ } catch (RuntimeException notExpected) {
+ fail();
+ }
+ }
+
+ protected void setUp() throws Exception {
+ display = Display.getCurrent();
+ if (display == null) {
+ display = new Display();
+ }
+ parent = new Shell(display, SWT.NONE);
+ }
+
+ protected void tearDown() throws Exception {
+ parent.dispose();
+ }
+
+ private void flushPendingEvents() {
+ while (display.readAndDispatch()) {
+ }
+ }
+
+}