Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 283263
Collapse All | Expand All

(-)src/org/eclipse/swt/widgets/Table.java (-2 / +2 lines)
Lines 699-709 Link Here
699
    if( itemArea.contains( point ) ) {
699
    if( itemArea.contains( point ) ) {
700
      int itemHeight = getItemHeight();
700
      int itemHeight = getItemHeight();
701
      int index = ( ( point.y - headerHeight ) / itemHeight ) - 1;
701
      int index = ( ( point.y - headerHeight ) / itemHeight ) - 1;
702
      if( point.y == 0 || point.y % itemHeight != 0 ) {
702
      if( point.y == headerHeight || point.y % itemHeight != 0 ) {
703
        index++;
703
        index++;
704
      }
704
      }
705
      index += topIndex;
705
      index += topIndex;
706
      if( index < itemCount ) {
706
      if( index >= 0 && index < itemCount ) {
707
        result = _getItem( index );
707
        result = _getItem( index );
708
      }
708
      }
709
    }
709
    }
(-)src/org/eclipse/swt/widgets/Table_Test.java (+17 lines)
Lines 1724-1729 Link Here
1724
  }
1724
  }
1725
  
1725
  
1726
  /*
1726
  /*
1727
   * 283263: ArrayIndexOutOfBoundsException when clicking on the Pixel Row just 
1728
   *         below the Table Header.
1729
   * https://bugs.eclipse.org/bugs/show_bug.cgi?id=283263
1730
   */
1731
  public void testGetItemBelowHeader() {
1732
    Display display = new Display();
1733
    Shell shell = new Shell( display );
1734
    Table table = new Table( shell, SWT.NONE );
1735
    table.setHeaderVisible( true );
1736
    table.setSize( 100, 100 );
1737
    new TableItem( table, SWT.NONE );
1738
    TableItem item = table.getItem( new Point( 10, table.getItemHeight() ) );
1739
    assertNotNull( item );
1740
    assertEquals( 0, table.indexOf( item ) );
1741
  }
1742
  
1743
  /*
1727
   * Ensures that checkData calls with an invalid index are silently ignored.
1744
   * Ensures that checkData calls with an invalid index are silently ignored.
1728
   * This may happen, when the itemCount is reduced during a SetData event.
1745
   * This may happen, when the itemCount is reduced during a SetData event.
1729
   * Queued SetData events may then have stale (out-of-bounds) indices.
1746
   * Queued SetData events may then have stale (out-of-bounds) indices.

Return to bug 283263