|
Re: Random ArrayIndexOutOfBoundsException with virtual custom draw tree [message #1742132 is a reply to message #1742101] |
Wed, 31 August 2016 16:04 |
Nicola Zanaga Messages: 56 Registered: July 2009 |
Member |
|
|
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.03676 seconds