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

Bug 410024

Summary: [TabFolder] Sends unwanted selection events when disposed
Product: [RT] RAP Reporter: Heiner Napp <h.napp>
Component: RWTAssignee: Project Inbox <rap-inbox>
Status: RESOLVED FIXED QA Contact:
Severity: major    
Priority: P3 CC: ruediger.herrmann
Version: 2.1   
Target Milestone: 2.2 M1   
Hardware: PC   
OS: Windows XP   
Whiteboard: sr211
Attachments:
Description Flags
Patch that fixes the issue none

Description Heiner Napp CLA 2013-06-06 03:11:59 EDT
Found in VERSION (2.1.0.20130527-1011)

TabFolder(Widget).sendEvent(Event) line: 700
TabFolder(Widget).notifyListeners(int, Event) line: 602
TabFolder.setSelection(int, boolean) line: 562
TabFolder.destroyItem(TabItem) line: 525
TabItem.releaseParent() line: 320
TabItem(Widget).dispose() line: 860
TabFolder.releaseChildren() line: 502
TabFolder(Widget).dispose() line: 856
Composite.releaseChildren() line: 855
Composite(Widget).dispose() line: 856
Comment 1 RĂ¼diger Herrmann CLA 2013-06-06 03:34:04 EDT
If a TabFolder is disposed, a selection event is sent for each TabItem it contains.
I think this is a regression that was introduced while resolving bug 407882.
Comment 2 Ivan Furnadjiev CLA 2013-06-06 03:49:53 EDT
(In reply to comment #1)
> If a TabFolder is disposed, a selection event is sent for each TabItem it
> contains.
> I think this is a regression that was introduced while resolving bug 407882.
Absolutely correct. Here is a test case:
@Test
public void testDispose_doesNotFireSelectionEvent() {
  createItems( folder, 3 );
  Listener listener = mock( Listener.class );
  for( int i = 0; i < 3; i++ ) {
    folder.getItem( i ).addListener( SWT.Selection, listener );
  }

  folder.dispose();

  verify( listener, times( 0 ) ).handleEvent( any( Event.class ) );
}
Comment 3 Ivan Furnadjiev CLA 2013-06-06 03:55:35 EDT
Correct test case:  
  @Test
  public void testDispose_doesNotFireSelectionEvent() {
    createItems( folder, 3 );
    Listener listener = mock( Listener.class );
    folder.addListener( SWT.Selection, listener );

    folder.dispose();

    verify( listener, times( 0 ) ).handleEvent( any( Event.class ) );
  }
Comment 4 Ivan Furnadjiev CLA 2013-06-06 04:22:53 EDT
Created attachment 232027 [details]
Patch that fixes the issue

This patch adds a check if folder isInDispose in TabFolder#destroyItem
It's too late to be fixed in 2.1. Will be pushed to master after the 2.1-maintenance branch is created. Marked as proposed fix for 2.1 SR1.
Comment 5 Ivan Furnadjiev CLA 2013-06-07 03:24:39 EDT
Fixed in master with commit e05b8873ecfc1bf8a6a90e2f2cb078c433f674a7.
Comment 6 Ralf Sternberg CLA 2013-08-08 10:05:24 EDT
+1 to backport this fix to 2.1.1
Comment 7 Ivan Furnadjiev CLA 2013-08-09 03:20:11 EDT
Backported to 2.1-maintenance branch with commit 5c1b5cee0b17336c348883da67f0b2c7c2564d89.