Project: SWT
Bug 92648 Tree,setTopItem can end up setting the wrong number
Reported: 2005-04-25 17:45:10 | Status: resolved fixed

The folloing code in setTopItem can result in negative values: <snip> int visibleItemCount = (clientArea.height - getHeaderHeight ()) / itemHeight; int index = Math.min (item.availableIndex, availableItemsCount - visibleItemCount); if (topIndex == index) return; update (); int change = topIndex - index; topIndex = index; getVerticalBar ().setSelection (topIndex); What is happpening on QNX is the following. I am trying to add the entry to a tree. It comes in and it says that the visibleItemsCount is 5 and the availableItemsCount is 1, this results in a value of -4 which is less than item.availableIndex ( which is 1 ). Further on down the line, change gets set to 4 because topIndex is 0 and index is -4. This is a problem because later on gc.copyArea gets called with a deltaY of 80 when it should be 0.

Files changed in fix:
bundles/org.eclipse.swt/Eclipse SWT/emulated/treetable/org/eclipse/swt/widgets/Tree.java