Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 489751

Summary: [GTK3] disposing an item will select a node
Product: [Eclipse Project] Platform Reporter: Thomas Singer <eclipse>
Component: SWTAssignee: Xi Yan <xixiyan>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: ericwill, niraj.modi
Version: 4.6Keywords: triaged
Target Milestone: 4.12 M1   
Hardware: PC   
OS: Linux   
See Also: https://git.eclipse.org/r/137466
https://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/?id=1dd8b6850f4caf6a689de54a9065a448fc455e46
https://git.eclipse.org/r/138564
https://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/?id=5a77dd402a843c024214579c91628da0a2671744
https://git.eclipse.org/r/139323
https://bugs.eclipse.org/bugs/show_bug.cgi?id=545994
Whiteboard:
Bug Depends on:    
Bug Blocks: 546333    
Attachments:
Description Flags
Sample code none

Description Thomas Singer CLA 2016-03-16 10:15:28 EDT
Please try the attached sample, one time with DISPOSE_DIRECTLY = true, one time with DISPOSE_DIRECTLY = false.

If the dispose occurs directly after tree.deselectAll, the next node after the disposed node will be selected again. That's not the case, when item.dispose is delayed. For SWT_GTK3=0 (and on Windows or OS X) this problem does not exist.
Comment 1 Thomas Singer CLA 2016-03-16 10:16:48 EDT
Created attachment 260343 [details]
Sample code
Comment 2 Thomas Singer CLA 2016-03-16 10:27:57 EDT
Workaround: before invoking tree.deselectAll, one has to select a different node (that not will be disposed):

	tree.setSelection(parentItem);
	tree.deselectAll();
	item.dispose();
Comment 3 Thomas Singer CLA 2016-03-16 10:45:59 EDT
... or simply invoke tree.deselectAll after item.dispose.
Comment 4 Eric Williams CLA 2018-05-07 13:15:49 EDT
I can still reproduce this issue on SWT master as of this morning, GTK3.22, and Fedora 28.
Comment 5 Eclipse Genie CLA 2019-02-22 11:54:30 EST
New Gerrit change created: https://git.eclipse.org/r/137466
Comment 7 Eric Williams CLA 2019-03-11 16:01:22 EDT
(In reply to Eclipse Genie from comment #6)
> Gerrit change https://git.eclipse.org/r/137466 was merged to [master].
> Commit:
> http://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/
> ?id=1dd8b6850f4caf6a689de54a9065a448fc455e46

In master now, thanks for the fix Xi.
Comment 8 Eclipse Genie CLA 2019-03-12 11:13:45 EDT
New Gerrit change created: https://git.eclipse.org/r/138564
Comment 10 Xi Yan CLA 2019-03-12 15:14:25 EDT
(In reply to Eclipse Genie from comment #9)
> Gerrit change https://git.eclipse.org/r/138564 was merged to [master].
> Commit:
> http://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/
> ?id=5a77dd402a843c024214579c91628da0a2671744

This fixes the regression from https://download.eclipse.org/eclipse/downloads/drops4/I20190312-0340/testresults/html/org.eclipse.ant.tests.ui_ep412I-unit-cen64-gtk3-java11_linux.gtk.x86_64_11.html

which is due to "gtk_changed" signal not blocked when disposing item. This patch also includes a SWT test checking that SWT.Selection event is not sent when item is disposed. Will verify build tomorrow.
Comment 11 Eclipse Genie CLA 2019-03-22 09:10:13 EDT
New Gerrit change created: https://git.eclipse.org/r/139323
Comment 12 Niraj Modi CLA 2019-04-08 05:31:20 EDT
(In reply to Eclipse Genie from comment #9)
> Gerrit change https://git.eclipse.org/r/138564 was merged to [master].
> Commit:
> http://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/
> ?id=5a77dd402a843c024214579c91628da0a2671744

Hi Xi,
The JUnit test "test_disposeItemNotTriggerSelection" added by above commit failing on Windows since sometime. Please have look:
https://download.eclipse.org/eclipse/downloads/drops4/I20190325-0105/testresults/html/org.eclipse.swt.tests_ep412I-unit-win32-java8_win32.win32.x86_64_8.0.html
Comment 13 Xi Yan CLA 2019-04-08 10:10:49 EDT
(In reply to Niraj Modi from comment #12)
> (In reply to Eclipse Genie from comment #9)
> > Gerrit change https://git.eclipse.org/r/138564 was merged to [master].
> > Commit:
> > http://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/
> > ?id=5a77dd402a843c024214579c91628da0a2671744
> 
> Hi Xi,
> The JUnit test "test_disposeItemNotTriggerSelection" added by above commit
> failing on Windows since sometime. Please have look:
> https://download.eclipse.org/eclipse/downloads/drops4/I20190325-0105/
> testresults/html/org.eclipse.swt.tests_ep412I-unit-win32-java8_win32.win32.
> x86_64_8.0.html

Hi, I don't have a Windows machine to test on, the test checks for whether disposing the tree item will trigger a SWT.Selection event. Does this happen on Windows?
Comment 14 Niraj Modi CLA 2019-04-10 08:31:01 EDT
(In reply to Xi Yan from comment #13)
> (In reply to Niraj Modi from comment #12)
> > (In reply to Eclipse Genie from comment #9)
> > > Gerrit change https://git.eclipse.org/r/138564 was merged to [master].
> > > Commit:
> > > http://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/
> > > ?id=5a77dd402a843c024214579c91628da0a2671744
> > 
> > Hi Xi,
> > The JUnit test "test_disposeItemNotTriggerSelection" added by above commit
> > failing on Windows since sometime. Please have look:
> > https://download.eclipse.org/eclipse/downloads/drops4/I20190325-0105/
> > testresults/html/org.eclipse.swt.tests_ep412I-unit-win32-java8_win32.win32.
> > x86_64_8.0.html
> 
> Hi, I don't have a Windows machine to test on, the test checks for whether
> disposing the tree item will trigger a SWT.Selection event.
Can you please share a test snippet for this scenario, I can try it out and let you know.

> Does this happen
> on Windows?
Yes, it's on Windows.
Comment 15 Niraj Modi CLA 2019-04-11 08:02:41 EDT
Ping!
Comment 16 Niraj Modi CLA 2019-04-11 08:19:48 EDT
Hi Xi,
I have raised separate bug 546333 to track the failing JUnit test on Windows.
Marking this as resolved.

Don't forget to verify this bug fix on GTK for 4.12 M1, Thanks!
Comment 17 Xi Yan CLA 2019-04-11 10:22:08 EDT
Verified in I20190410-0600.