Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Random ArrayIndexOutOfBoundsException with virtual custom draw tree
Random ArrayIndexOutOfBoundsException with virtual custom draw tree [message #1742101] Wed, 31 August 2016 12:31 Go to next message
Nicola Zanaga is currently offline Nicola ZanagaFriend
Messages: 56
Registered: July 2009
Member
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 16:04 Go to previous messageGo to next message
Nicola Zanaga is currently offline Nicola ZanagaFriend
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;
			}

Re: Random ArrayIndexOutOfBoundsException with virtual custom draw tree [message #1742279 is a reply to message #1742132] Thu, 01 September 2016 12:28 Go to previous messageGo to next message
Nicola Zanaga is currently offline Nicola ZanagaFriend
Messages: 56
Registered: July 2009
Member
The code above doesn't solve the problem.

However, I solved preventing any structural changes to the tree during 'SetData' event
Re: Random ArrayIndexOutOfBoundsException with virtual custom draw tree [message #1742284 is a reply to message #1742132] Thu, 01 September 2016 12:38 Go to previous message
Nicola Zanaga is currently offline Nicola ZanagaFriend
Messages: 56
Registered: July 2009
Member
The code above doesn't solve the problem.

However, I solved preventing any structural changes to the tree during 'SetData' event
Previous Topic: Switching Eclipse Neon to use a more recent version of SWT
Next Topic:How to get the innerHTML of object on mouseover with SWT browser
Goto Forum:
  


Current Time: Tue Mar 19 09:02:41 GMT 2024

Powered by FUDForum. Page generated in 0.02287 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top