| Summary: | Focus lost when focused widget is disposed | ||||||
|---|---|---|---|---|---|---|---|
| Product: | [Eclipse Project] Platform | Reporter: | Travis Hume <travis.hume> | ||||
| Component: | SWT | Assignee: | Ian Pun <ipun> | ||||
| Status: | RESOLVED FIXED | QA Contact: | |||||
| Severity: | normal | ||||||
| Priority: | P3 | CC: | akurtakov, arunkumar.thondapu, billy.biggs, cocoakevin, daniel_megert, douglas.pollock, eclipse, ericwill, gheorghe, john.arthorne, markus.kell.r, Michael.Valenta | ||||
| Version: | 3.0 | ||||||
| Target Milestone: | 4.7 M3 | ||||||
| Hardware: | PC | ||||||
| OS: | Linux-GTK | ||||||
| See Also: |
https://git.eclipse.org/r/80517 https://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/?id=52881b02b736327002428947c3a54bd5fb1b6761 https://git.eclipse.org/r/80748 https://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/?id=03e505a39be2165463f88264099ee8921b2bb263 https://git.eclipse.org/r/80853 https://git.eclipse.org/r/81008 https://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/?id=67e18320e2682697b68f564901b6459633fc9938 |
||||||
| Whiteboard: | |||||||
| Attachments: |
|
||||||
|
Description
Travis Hume
Can't recreate this. Unclear what you mean by "perform an update". Moving to UI team. There is no focus control when this problem happens. I believe this is an SWT problem. I don't believe that the focus control should ever be null if the workbench window has focus. I found that to recreate the problem it helps to have existing changes. Then "Update" or "Override and Update" on all changes. The tree gets destroyed when the update completes, and is replaced with some kind of text widget giving you helpful advice about no changes. At this point, the focus control becomes null. However, if I create changes while my workspace is already around, it doesn't seem to happen all the time. I'm not sure why. Is this Linux GTK or Linux Motif? Linux GTK+ Felipe, can you find out why the focus control is null? I can't reproduce this bug. Doug, can you help me ? Please let me know what is your linux, your desktop, and your window manager. Gentoo linux kernel v2.6.8.1 gtk+ v2.4.4 glibc-2.3.3 Gnome 2.6.2 Window manager: metacity v2.8.1 This is my machine, but I've also seen this behaviour on our pairing stations with run mandrake 9.3 I was able to reproduce this bug on old builds but I can't reproduce it with build I20040907. Doug, Travis, can you guys reproduce this problem on I20040907 ? Okay, when I start eclipse I can not reproduce this problem, but after a couple hours working on Eclipse I try again and then I could recreate it all the time. Something has to happen before I can reproduce the bug, I just don't know what. This is easy for me to reproduce. It has never failed to occur. Here's a test case. When the second Text is disposed on its key down, the focus
goes nowhere and the display filter does not work. On Windows, when the second
Text is disposed, focus goes to the first Text.
public static void main(String[] args) {
Display display = new Display();
Shell shell = new Shell(display);
display.addFilter(SWT.KeyDown, new Listener() {
int count = 0;
public void handleEvent(Event event) {
System.out.println("Got a key down: " + count);
count++;
}
});
Text text = new Text(shell, SWT.BORDER);
text.setBounds(20, 20, 200, 40);
final Text text2 = new Text(shell, SWT.BORDER);
text2.setBounds(80, 80, 200, 40);
text2.addListener(SWT.KeyDown, new Listener() {
public void handleEvent(Event event) {
System.out.println("ok, here goes");
text2.dispose();
}
});
shell.open();
while(!shell.isDisposed()) {
if(!display.readAndDispatch()) display.sleep();
}
display.dispose();
}
Created attachment 20575 [details]
Proposed patch
Here's a proposal for a fix. I think it's right, but it's dangerous to mess
with this sort of thing.
Has that patch been included in a build yet? I tried N20050503-0010 this morning without success. This patch is not safe and still needs work. It is not included in any builds yet. *** Bug 97555 has been marked as a duplicate of this bug. *** *** Bug 113278 has been marked as a duplicate of this bug. *** Confirmed that is is still an issue with 3.3 M4. Easy to reproduce: 1. Alt-Shift-Q Y (open sync view) 2. F5 (re-sync with server, refresh) 3. F12 (Should return to editor, but does nothing) I, and my other keyboard only friends run into this constantly. Note that we are now using subversive but have seen the problem with subclipse and the standard cvs plugin. *** Bug 164316 has been marked as a duplicate of this bug. *** Still happens on 3.4 R4 (tested the snippet in 12). Bog, haven't you fixed bugs in this area recently ? This is still reproducible. Assigning to Ian. *** Bug 123127 has been marked as a duplicate of this bug. *** I've added the proposed patch. I haven't discovered any possible use case that could case a dangerous side effect. Does anyone have a potential use case that would? New Gerrit change created: https://git.eclipse.org/r/80517 Gerrit change https://git.eclipse.org/r/80517 was merged to [master]. Commit: http://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/?id=52881b02b736327002428947c3a54bd5fb1b6761 (In reply to Eclipse Genie from comment #25) > Gerrit change https://git.eclipse.org/r/80517 was merged to [master]. > Commit: > http://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/ > ?id=52881b02b736327002428947c3a54bd5fb1b6761 In master now, thanks for the patch Billy, and Ian for the investigation. New Gerrit change created: https://git.eclipse.org/r/80748 Gerrit change https://git.eclipse.org/r/80748 was merged to [master]. Commit: http://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/?id=03e505a39be2165463f88264099ee8921b2bb263 This caused a lot of NPEs in latest nightly build: java.lang.NullPointerException at org.eclipse.swt.custom.CCombo.isFocusControl(CCombo.java:1091) at org.eclipse.swt.custom.CCombo.setFocus(CCombo.java:1490) at org.eclipse.swt.widgets.Control.fixFocus(Control.java:217) at org.eclipse.swt.widgets.Control.releaseWidget(Control.java:4010) Can be seen at http://download.eclipse.org/eclipse/downloads/drops4/N20160908-2000/testresults/html/org.eclipse.ui.tests_ep47N-unit-cen64_linux.gtk.x86_64_8.0.html . I have reverted it - the way CCombo is implemented seems to cause race(?) condition. Before proceeding further on this bug please implement Test_org_eclipse_swt_custom_CCombo.test_isFocusControl and test_setFocus to not be empty methods - no matter how simple the tests are they should catch NPEs. Moving to M3 as there is more work to be done here... New Gerrit change created: https://git.eclipse.org/r/80853 (In reply to Alexander Kurtakov from comment #29) > This caused a lot of NPEs in latest nightly build: > java.lang.NullPointerException > at org.eclipse.swt.custom.CCombo.isFocusControl(CCombo.java:1091) > at org.eclipse.swt.custom.CCombo.setFocus(CCombo.java:1490) > at org.eclipse.swt.widgets.Control.fixFocus(Control.java:217) > at org.eclipse.swt.widgets.Control.releaseWidget(Control.java:4010) > > Can be seen at > http://download.eclipse.org/eclipse/downloads/drops4/N20160908-2000/ > testresults/html/org.eclipse.ui.tests_ep47N-unit-cen64_linux.gtk.x86_64_8.0. > html . > > I have reverted it - the way CCombo is implemented seems to cause race(?) > condition. Before proceeding further on this bug please implement > Test_org_eclipse_swt_custom_CCombo.test_isFocusControl and test_setFocus to > not be empty methods - no matter how simple the tests are they should catch > NPEs. Hey Alex, I just committed a patch within Ccombo that will deal with the underlying issue; setFocusControl() was not overwritten correctly and did not take care of null exceptions. I have fixed that in Ccombo, but will definitely work on implementing the tests as well. *** Bug 185538 has been marked as a duplicate of this bug. *** New Gerrit change created: https://git.eclipse.org/r/81008 Gerrit change https://git.eclipse.org/r/81008 was merged to [master]. Commit: http://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/?id=67e18320e2682697b68f564901b6459633fc9938 (In reply to Eclipse Genie from comment #35) > Gerrit change https://git.eclipse.org/r/81008 was merged to [master]. > Commit: > http://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/ > ?id=67e18320e2682697b68f564901b6459633fc9938 Merged updated fix, thanks for the patch Ian. |