diff options
| author | Ian Pun | 2016-09-06 19:22:53 +0000 |
|---|---|---|
| committer | Eric Williams | 2016-09-16 20:08:55 +0000 |
| commit | 67e18320e2682697b68f564901b6459633fc9938 (patch) | |
| tree | b6a8a6fb9ca385d2c3d05780ca440b9d7ab29827 | |
| parent | d4023f7a2ad77b70b0787eefe4bf1696554cc0dd (diff) | |
| download | eclipse.platform.swt-67e18320e2682697b68f564901b6459633fc9938.tar.gz eclipse.platform.swt-67e18320e2682697b68f564901b6459633fc9938.tar.xz eclipse.platform.swt-67e18320e2682697b68f564901b6459633fc9938.zip | |
Bug 69650 - Focus lost when focused widget is disposed
Added additional test cases for ccombo for setFocus() and
isFocusControl(). This is copied from the implementations from Control
and Button.
Change-Id: I7e0579430579741599583cbe41d20e9d4b0c8a48
Signed-off-by: Ian Pun <ipun@redhat.com>
3 files changed, 7 insertions, 2 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CCombo.java b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CCombo.java index abbfaf9bb6..5d995e83f8 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CCombo.java +++ b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CCombo.java @@ -1088,7 +1088,8 @@ boolean isDropped () { @Override public boolean isFocusControl () { checkWidget(); - if (text.isFocusControl () || arrow.isFocusControl () || list.isFocusControl () || popup.isFocusControl ()) { + if ((text != null && text.isFocusControl ()) || (arrow != null && arrow.isFocusControl ()) || + (list != null && list.isFocusControl ()) || (popup != null && popup.isFocusControl ())) { return true; } return super.isFocusControl (); diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java index 9d94298b5e..eccd99be13 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java @@ -4005,7 +4005,9 @@ void releaseParent () { @Override void releaseWidget () { + boolean hadFocus = display.getFocusControl() == this; super.releaseWidget (); + if (hadFocus) fixFocus (this); if (display.currentControl == this) display.currentControl = null; display.removeMouseHoverTimeout (handle); long /*int*/ imHandle = imHandle (); diff --git a/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_custom_CCombo.java b/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_custom_CCombo.java index fbf157e011..efd64ac2cb 100644 --- a/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_custom_CCombo.java +++ b/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_custom_CCombo.java @@ -86,6 +86,7 @@ public void test_getChildren() { @Override @Test public void test_isFocusControl() { + assertTrue(!ccombo.isFocusControl()); } @Test @@ -129,6 +130,7 @@ public void test_setEnabledZ() { @Override @Test public void test_setFocus() { + assertTrue(!ccombo.setFocus()); } @Override @@ -164,7 +166,7 @@ private void add() { public void test_consistency_MouseSelection () { add(); consistencyPrePackShell(); - consistencyEvent(ccombo.getSize().x-10, 5, 30, ccombo.getItemHeight()*2, + consistencyEvent(ccombo.getSize().x-10, 5, 30, ccombo.getItemHeight()*2, ConsistencyUtility.SELECTION); } |
