Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 103757 Details for
Bug 235368
[table] ArrayIndexOutOfBoundsException in virtual TableViewer
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
Patch for solving Array Index Out of bounds errors for the given scenario (see first attachment)
clipboard.txt (text/plain), 5.13 KB, created by
Stefan Röck
on 2008-06-05 11:20:29 EDT
(
hide
)
Description:
Patch for solving Array Index Out of bounds errors for the given scenario (see first attachment)
Filename:
MIME Type:
Creator:
Stefan Röck
Created:
2008-06-05 11:20:29 EDT
Size:
5.13 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.rap.rwt.q07 >Index: src/org/eclipse/swt/internal/widgets/tablekit/TableLCA.java >=================================================================== >RCS file: /cvsroot/technology/org.eclipse.rap/org.eclipse.rap.rwt.q07/src/org/eclipse/swt/internal/widgets/tablekit/TableLCA.java,v >retrieving revision 1.2 >diff -u -r1.2 TableLCA.java >--- src/org/eclipse/swt/internal/widgets/tablekit/TableLCA.java 2 Jun 2008 17:03:37 -0000 1.2 >+++ src/org/eclipse/swt/internal/widgets/tablekit/TableLCA.java 5 Jun 2008 15:17:50 -0000 >@@ -83,7 +83,7 @@ > Table table = ( Table )widget; > readTopIndex( table ); // topIndex MUST be read *before* processSetData > readSelection( table ); >- processSetData( table ); >+ readSetData( table ); > readWidgetSelected( table ); > readWidgetDefaultSelected( table ); > ControlLCAUtil.processMouseEvents( table ); >@@ -169,7 +169,7 @@ > } > } > >- private static void processSetData( final Table table ) { >+ private static void readSetData( final Table table ) { > if( WidgetLCAUtil.wasEventSent( table, JSConst.EVENT_SET_DATA ) ) { > HttpServletRequest request = ContextProvider.getRequest(); > String value = request.getParameter( JSConst.EVENT_SET_DATA_INDEX ); >@@ -178,7 +178,9 @@ > ITableAdapter tableAdapter = ( ITableAdapter )adapter; > for( int i = 0; i < indices.length; i++ ) { > int index = Integer.parseInt( indices[ i ] ); >- tableAdapter.checkData( index ); >+ if (index >-1 && index < table.getItemCount()) { >+ tableAdapter.checkData( index ); >+ } > } > } > } >@@ -186,17 +188,21 @@ > private void readWidgetSelected( final Table table ) { > if( WidgetLCAUtil.wasEventSent( table, JSConst.EVENT_WIDGET_SELECTED ) ) { > // TODO [rh] do something about when index points to unresolved item! >- TableItem item = table.getItem( getWidgetSelectedIndex() ); >- int detail = getWidgetSelectedDetail(); >- int id = SelectionEvent.WIDGET_SELECTED; >- SelectionEvent event = new SelectionEvent( table, >- item, >- id, >- new Rectangle( 0, 0, 0, 0 ), >- "", >- true, >- detail ); >- event.processEvent(); >+ final int widgetSelectedIndex = getWidgetSelectedIndex(); >+ // Bugfix: check if index is valid before firing event to avoid problems with fast scrolling >+ if (widgetSelectedIndex > -1 && widgetSelectedIndex < table.getItemCount()) { >+ TableItem item = table.getItem( widgetSelectedIndex ); >+ int detail = getWidgetSelectedDetail(); >+ int id = SelectionEvent.WIDGET_SELECTED; >+ SelectionEvent event = new SelectionEvent( table, >+ item, >+ id, >+ new Rectangle( 0, 0, 0, 0 ), >+ "", >+ true, >+ detail ); >+ event.processEvent(); >+ } > } > } > >#P org.eclipse.rap.rwt >Index: src/org/eclipse/swt/widgets/Table.java >=================================================================== >RCS file: /cvsroot/technology/org.eclipse.rap/org.eclipse.rap.rwt/src/org/eclipse/swt/widgets/Table.java,v >retrieving revision 1.38 >diff -u -r1.38 Table.java >--- src/org/eclipse/swt/widgets/Table.java 2 Jun 2008 17:03:34 -0000 1.38 >+++ src/org/eclipse/swt/widgets/Table.java 5 Jun 2008 15:17:52 -0000 >@@ -2131,17 +2131,24 @@ > } > > final void checkData( final TableItem item, final int index ) { >- if( ( style & SWT.VIRTUAL ) != 0 && !item.cached ) { >- ProcessActionRunner.add( new Runnable() { >+ if( ( style & SWT.VIRTUAL ) != 0 && !item.cached ) { >+ ProcessActionRunner.add( new Runnable() { > public void run() { >- item.cached = true; >- SetDataEvent event = new SetDataEvent( Table.this, item, index ); >- event.processEvent(); >- // widget could be disposed at this point >- if( isDisposed() || item.isDisposed() ) { >- SWT.error( SWT.ERROR_WIDGET_DISPOSED ); >- } >- } >+ item.cached = true; >+ SetDataEvent event = new SetDataEvent( Table.this, item, index ); >+ // Check if index is valid to avoid problems when scrolling fast down >+ if (index > -1 && index < Table.this.getItemCount()) { >+ event.processEvent(); >+ } >+ // the event can change the item count so check index validity before continue >+ if (index > -1 && index < Table.this.getItemCount()) { >+ // widget could be disposed at this point >+ if( isDisposed() || item.isDisposed() ) { >+ System.out.println("index " + index + " count " + Table.this.getItemCount()); >+ SWT.error( SWT.ERROR_WIDGET_DISPOSED ); >+ } >+ } >+ } > } ); > } > }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 235368
:
103345
|
103552
|
103757
|
103908
|
104115