Buggy code:
if ( order == 0 ) { int [ ] disclosure = new int [ 1 ] ; boolean [ ] expandableRows = new boolean [ 1 ] ; OS . GetDataBrowserListViewDisclosureColumn ( handle , disclosure , expandableRows ) ; if ( ( disclosure [ 0 ] ) != ( column . id ) ) { OS . SetDataBrowserListViewDisclosureColumn ( handle , column . id , expandableRows [ 0 ] ) ; } } column . sendEvent ( Move ) ; } } } int [ ] property = new int [ 1 ] ; OS . GetDataBrowserSortProperty ( handle , property ) ; if ( ( property [ 0 ] ) != 0 ) { for ( int i = 0 ; i < ( columnCount ) ; i ++ ) { TreeColumn column = columns [ i ] ; if ( ( property [ 0 ] ) == ( column . id ) ) { column . postEvent ( ( ( clickCount ) == 2 ? SWT . DefaultSelection : SWT . Selection ) ) ; break ; } } OS . SetDataBrowserSortProperty ( handle , 0 ) ; if ( ( ( ( sortColumn ) != null ) && ( ! ( sortColumn . isDisposed ( ) ) ) ) && ( ( sortDirection ) != ( SWT . NONE ) ) ) { OS . SetDataBrowserSortProperty ( handle , sortColumn . id ) ; OS . SetDataBrowserSortOrder ( handle , ( ( sortDirection ) == ( SWT . DOWN ) ? ( ( short ) ( 2 ) ) : ( ( short ) ( 1 ) ) ) ) ; } } return OS . noErr ; } int index = id - 1 ; if ( ! ( ( 0 <= index ) && ( index < ( items . length ) ) ) ) return OS . noErr ; TreeItem item = items [ index ] ; switch ( message ) { case OS . kDataBrowserItemSelected : case OS . kDataBrowserItemDeselected : { wasSelected = true ; if ( ignoreSelect ) break ; int [ ] first = new int [ 1 ] ; int [ ] last = new int [ 1 ] ; OS . GetDataBrowserSelectionAnchor ( handle , first , last ) ; boolean selected = false ; if ( ( ( style ) & ( SWT . MULTI ) ) != 0 ) { int modifiers = OS . GetCurrentEventKeyModifiers ( ) ; if ( ( modifiers & ( OS . shiftKey ) ) != 0 ) { if ( message == ( OS . kDataBrowserItemSelected ) ) { selected = ( ( first [ 0 ] ) == id ) || ( ( last [ 0 ] ) == id ) ; } else { selected = ( id == ( anchorFirst ) ) || ( id == ( anchorLast ) ) ; } } else { if ( ( modifiers & ( OS . cmdKey ) ) != 0 ) { selected = true ; } else { selected = ( first [ 0 ] ) == ( last [ 0 ] ) ; } } } else { selected = message == ( OS . kDataBrowserItemSelected ) ; } if ( selected ) { anchorFirst = first [ 0 ] ; anchorLast = last [ 0 ] ; Event event = new Event ( ) ; event . item = item ; postEvent ( Selection , event ) ; } break ; } case OS . kDataBrowserItemDoubleClicked : { wasSelected = true ; Event event = new Event ( ) ; event . item = item ; postEvent ( DefaultSelection , event ) ; break ; } case OS . kDataBrowserContainerClosing : { int ptr = OS . NewHandle ( 0 ) ; <START_BUG> if ( ( OS . GetDataBrowserItems ( handle , id , true , kDataBrowserItemAnyState , ptr ) ) == ( OS . noErr ) ) { <END_BUG> int count = ( OS . GetHandleSize ( ptr ) ) // 4 ; visibleCount -= count ; } OS . DisposeHandle ( ptr ) ; ptr = OS . NewHandle ( 0 ) ; if ( ( OS . GetDataBrowserItems ( handle , id , true , kDataBrowserItemIsSelected , ptr ) ) == ( OS . noErr ) ) { int count = ( OS . GetHandleSize ( ptr ) ) // 4 ; if ( count > 0 ) { int [ ] ids = new int [ count ] ; OS . HLock ( ptr ) ; int [ ] start = new int [ 1 ] ; OS . memcpy ( start , ptr , 4 ) ; OS . memcpy ( ids , start [ 0 ] , ( count * 4 ) ) ; OS . HUnlock ( ptr ) ; ignoreSelect = true ; int [ ] selectionFlags = null ; if ( ( ( style ) & ( SWT . SINGLE ) ) != 0 ) { selectionFlags = new int [ 1 ] ; OS . GetDataBrowserSelectionFlags ( handle , selectionFlags ) ; OS . SetDataBrowserSelectionFlags ( handle , ( ( selectionFlags [ 0 ] ) & ( ~ ( OS . kDataBrowserNeverEmptySelectionSet ) ) ) ) ; } OS . SetDataBrowserSelectedItems ( handle , ids . length , ids , kDataBrowserItemsRemove ) ; if ( ( ( style ) & ( SWT . SINGLE ) ) != 0 ) { OS . SetDataBrowserSelectionFlags ( handle , selectionFlags [ 0 ] ) ; } ignoreSelect = false ; Event event = new Event ( ) ; event . item = item ; sendEvent ( Selection , event ) ; } } OS . DisposeHandle ( ptr ) ; break ; } case OS . kDataBrowserContainerClosed : { wasExpanded = true ; if ( ! ( ignoreExpand ) ) { Event event = new Event ( ) ;

Fix:
if ( ( OS . GetDataBrowserItems ( handle , id , false , kDataBrowserItemAnyState , ptr ) ) == ( OS . noErr ) ) {