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 235368 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/swt/widgets/Table.java (-1 / +3 lines)
Lines 127-133 Link Here
127
    }
127
    }
128
128
129
    public void checkData( final int index ) {
129
    public void checkData( final int index ) {
130
      Table.this.checkData( Table.this._getItem( index ), index );
130
      if( index >= 0 && index < Table.this.itemCount ) {
131
        Table.this.checkData( Table.this._getItem( index ), index );
132
      }
131
    }
133
    }
132
134
133
    public int getDefaultColumnWidth() {
135
    public int getDefaultColumnWidth() {
(-)src/org/eclipse/swt/internal/widgets/tablekit/TableLCA.java (-2 / +2 lines)
Lines 83-89 Link Here
83
    Table table = ( Table )widget;
83
    Table table = ( Table )widget;
84
    readTopIndex( table ); // topIndex MUST be read *before* processSetData
84
    readTopIndex( table ); // topIndex MUST be read *before* processSetData
85
    readSelection( table );
85
    readSelection( table );
86
    processSetData( table );
86
    readSetData( table );
87
    readWidgetSelected( table );
87
    readWidgetSelected( table );
88
    readWidgetDefaultSelected( table );
88
    readWidgetDefaultSelected( table );
89
    ControlLCAUtil.processMouseEvents( table );
89
    ControlLCAUtil.processMouseEvents( table );
Lines 169-175 Link Here
169
    }
169
    }
170
  }
170
  }
171
  
171
  
172
  private static void processSetData( final Table table ) {
172
  private static void readSetData( final Table table ) {
173
    if( WidgetLCAUtil.wasEventSent( table, JSConst.EVENT_SET_DATA ) ) {
173
    if( WidgetLCAUtil.wasEventSent( table, JSConst.EVENT_SET_DATA ) ) {
174
      HttpServletRequest request = ContextProvider.getRequest();
174
      HttpServletRequest request = ContextProvider.getRequest();
175
      String value = request.getParameter( JSConst.EVENT_SET_DATA_INDEX );
175
      String value = request.getParameter( JSConst.EVENT_SET_DATA_INDEX );
(-)src/org/eclipse/swt/widgets/Table_Test.java (-6 / +20 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2002-2006 Innoopract Informationssysteme GmbH.
2
 * Copyright (c) 2002-2008 Innoopract Informationssysteme GmbH.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 8-14 Link Here
8
 * Contributors:
8
 * Contributors:
9
 *     Innoopract Informationssysteme GmbH - initial API and implementation
9
 *     Innoopract Informationssysteme GmbH - initial API and implementation
10
 ******************************************************************************/
10
 ******************************************************************************/
11
12
package org.eclipse.swt.widgets;
11
package org.eclipse.swt.widgets;
13
12
14
import junit.framework.TestCase;
13
import junit.framework.TestCase;
Lines 424-433 Link Here
424
    Object adapter = table.getAdapter( ITableAdapter.class );
423
    Object adapter = table.getAdapter( ITableAdapter.class );
425
    ITableAdapter tableAdapter = ( ITableAdapter )adapter;
424
    ITableAdapter tableAdapter = ( ITableAdapter )adapter;
426
425
427
//    table.setItemCount( 100 );
428
//    table.setSelection( 90 );
429
//    table.setSize( 501, 501 );
430
//    table.setItemCount( 10 );
431
    table.setItemCount( 100 );
426
    table.setItemCount( 100 );
432
    table.setSelection( 99 );
427
    table.setSelection( 99 );
433
    table.setSize( 501, 501 );
428
    table.setSize( 501, 501 );
Lines 1447-1452 Link Here
1447
    assertNotNull( item );
1442
    assertNotNull( item );
1448
    assertEquals( 0, table.indexOf( item ) );
1443
    assertEquals( 0, table.indexOf( item ) );
1449
  }
1444
  }
1445
1446
  /*
1447
   * Ensures that checkData calls with an invalid index are silently ignored.
1448
   * This may happen, when the itemCount is reduced during a SetData event.
1449
   * Queued SetData events may then have stale (out-of-bounds) indices.
1450
   * See 235368: [table] [table] ArrayIndexOutOfBoundsException in virtual 
1451
   *     TableViewer 
1452
   *     https://bugs.eclipse.org/bugs/show_bug.cgi?id=235368
1453
   */
1454
  public void testCheckDataWithInvalidIndex() {
1455
    RWTFixture.fakePhase( PhaseId.PROCESS_ACTION );
1456
    Display display = new Display();
1457
    Shell shell = new Shell( display );
1458
    Table table = new Table( shell, SWT.VIRTUAL );
1459
    table.setItemCount( 10 );
1460
    ITableAdapter adapter
1461
      = ( ITableAdapter )table.getAdapter( ITableAdapter.class );
1462
    adapter.checkData( 99 );
1463
  }
1450
  
1464
  
1451
  private static void clearColumns( final Table table ) {
1465
  private static void clearColumns( final Table table ) {
1452
    while( table.getColumnCount() > 0 ) {
1466
    while( table.getColumnCount() > 0 ) {

Return to bug 235368