Community
Participate
Working Groups
Build Identifier: M20110210-1200, RAP runtime 1.4 M7 Infinite loop in this code: --- public void setItemCount( int count ) { checkWidget(); int newItemCount = Math.max( 0, count ); if( newItemCount != itemCount ) { while( newItemCount < itemCount ) { // infinite loop here TableItem item = items[ newItemCount ]; if( item != null && !item.isDisposed() ) { item.dispose(); } else { destroyItem( null, newItemCount ); } } ... --- Table control is in dispose state and destroyItem method does not decrease 'itemCount' member. My fix is: --- final void destroyItem( TableItem item, int index ) { if( !isInDispose() ) { ... // unchached code } else itemCount--; } --- Reproducible: Always Steps to Reproduce: 1. Run Application 2. Press 'Close' button.
Created attachment 196179 [details] Code to reproduce bug.
I can reproduce it with your snippet too. What bugs me, is the call to setItemCount in the dispose event (inputChanged is called in the dispose event). Is this working in RCP?
Test case that loops forever. Works fin in SWT. public void testSetItemCountInDisposeListener() { Fixture.fakePhase( PhaseId.PROCESS_ACTION ); final Table table = new Table( shell, SWT.VIRTUAL ); table.setItemCount( 10 ); table.addDisposeListener( new DisposeListener() { public void widgetDisposed( DisposeEvent e ) { table.setItemCount( 0 ); } } ); table.dispose(); }
We should check the same scenario on Tree.
Created attachment 196290 [details] Proposed patch The solution is to not execute the code at all in Table#setItemCount if table is in dispose.
I checked Tree/TreeItem too and they are not affected - Tree/TreeItem#setItemCount does not rely on "hidden" decrementation of itemCount field.
+1 for the patch. I agree that not executing setItemCount makes most sense and is safe. But I'd suggest that we include a comment with the bug number in the first added test. Since it contains no asserts, it has the potential of being deleted if its meaning is unclear.
Applied patch to CVS HEAD and v14_Maintenance branch with additional comment on the first test as suggested in comment #7.