Random ArrayIndexOutOfBoundsException with virtual custom draw tree [message #1742101] |
Wed, 31 August 2016 08:31  |
Eclipse User |
|
|
|
I have a random problem using virtual tree (and custom draw tree)
During repaint event, sometimes, when the tree items change, I get an ArrayIndexOutOfBoundsException error on swt library. Here the stack trace:
java.lang.ArrayIndexOutOfBoundsException: 7
at org.eclipse.swt.widgets.Tree._getItem(Tree.java:256)
at org.eclipse.swt.widgets.Tree.getItem(Tree.java:3176)
at org.eclipse.swt.widgets.Tree.CDDS_ITEMPREPAINT(Tree.java:935)
at org.eclipse.swt.widgets.Tree.wmNotifyChild(Tree.java:7541)
at org.eclipse.swt.widgets.Control.wmNotify(Control.java:5817)
at org.eclipse.swt.widgets.Composite.wmNotify(Composite.java:2033)
at org.eclipse.swt.widgets.Control.WM_NOTIFY(Control.java:5371)
at org.eclipse.swt.widgets.Control.windowProc(Control.java:4847)
at org.eclipse.swt.widgets.Display.windowProc(Display.java:5115)
at org.eclipse.swt.internal.win32.OS.CallWindowProcW(Native Method)
at org.eclipse.swt.internal.win32.OS.CallWindowProc(OS.java:2446)
at org.eclipse.swt.widgets.Tree.callWindowProc(Tree.java:1552)
at org.eclipse.swt.widgets.Control.windowProc(Control.java:4889)
at org.eclipse.swt.widgets.Tree.windowProc(Tree.java:6074)
at org.eclipse.swt.widgets.Display.windowProc(Display.java:5102)
at org.eclipse.swt.internal.win32.OS.DispatchMessageW(Native Method)
at org.eclipse.swt.internal.win32.OS.DispatchMessage(OS.java:2552)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3814)
I'm using swt-4.6RC4a-win32-win32-x86_64
on windows 7 64 bit
It's seems sometimes the internal variable 'items' in 'Tree' has less element than the parameter in the event (maybe a paint event for an item is fired after the items clear ?)
|
|
|
Re: Random ArrayIndexOutOfBoundsException with virtual custom draw tree [message #1742132 is a reply to message #1742101] |
Wed, 31 August 2016 12:04   |
Eclipse User |
|
|
|
I can't create a snippet, but I think I've found where the problem starts:
Class "Tree", Function:
LRESULT wmNotifyChild (NMHDR hdr, long /*int*/ wParam, long /*int*/ lParam)
from line 7476 the code:
if (item == null) break;
if (item.isDisposed ()) break;
if (!item.cached) {
if ((style & SWT.VIRTUAL) != 0) {
if (!checkData (item, false)) break;
}
if (painted) item.cached = true;
}
The problem is that 'tem.isDisposed' is checked before 'checkData', but not after.
During checkData, control executes 'sendEvent (SWT.SetData, event);'
In this event, the items can change (for example using 'setItemCount' or other functions) (and the item itself could be disposed).
So I think the code should be:
if (item == null) break;
if (item.isDisposed ()) break;
if (!item.cached) {
if ((style & SWT.VIRTUAL) != 0) {
if (!checkData (item, false)) break;
// recheck item disposed
if (item.isDisposed ()) break;
}
if (painted) item.cached = true;
}
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.04084 seconds