views:

468

answers:

3

After recently installing Windows 7 Professional, I'm getting a strange problem removing a TableItem from a populated Table in SWT. It is specific to Windows 7 and to the SWT.VIRTUAL style constant for the table.

Consider the following code:

table = new Table(parent, SWT.VIRTUAL | Skin.SCROLL_STYLE |
                          SWT.FULL_SELECTION | SWT.BORDER);
TableItem item = new TableItem(table, SWT.NONE);
item.setText("Table item");
table.remove(0);

This causes a StackOverflowError as follows:

Caused by: java.lang.StackOverflowError
    at org.eclipse.swt.internal.win32.OS.CallWindowProcW(Native Method)
    at org.eclipse.swt.internal.win32.OS.CallWindowProc(OS.java:2312)
    at org.eclipse.swt.widgets.Table.callWindowProc(Table.java:334)
    at org.eclipse.swt.widgets.Table.callWindowProc(Table.java:200)
    at org.eclipse.swt.widgets.Control.windowProc(Control.java:4036)
    at org.eclipse.swt.widgets.Table.windowProc(Table.java:5520)
    at org.eclipse.swt.widgets.Display.windowProc(Display.java:4602)
    at org.eclipse.swt.internal.win32.OS.SendMessageW(Native Method)
    at org.eclipse.swt.internal.win32.OS.SendMessage(OS.java:3106)
    at org.eclipse.swt.widgets.Table.wmNotifyChild(Table.java:6319)
    at org.eclipse.swt.widgets.Control.wmNotify(Control.java:4877)
    at org.eclipse.swt.widgets.Composite.wmNotify(Composite.java:1757)
    at org.eclipse.swt.widgets.Control.WM_NOTIFY(Control.java:4507)
    at org.eclipse.swt.widgets.Control.windowProc(Control.java:4000)
    at org.eclipse.swt.widgets.Display.windowProc(Display.java:4602)
    at org.eclipse.swt.internal.win32.OS.CallWindowProcW(Native Method)
    at ...

As shown above, the stack cycles from the Display's windowProc call to the OS' CallWindowProcW; this leads me to suspect that it has something to do with the Windows 7-specific implementation of SWT. The stack trace eventually originates from the table.remove(0) line.

Testing under Vista, XP or Mac OS X gives no problems.

Removing the SWT.VIRTUAL style constant resolves the problem, but doesn't allow for custom objects in the table.

It would seem that this is a SWT bug, or am I missing something?

+2  A: 

Looks like a bug. Report it to the SWT guys with a test case.

Aaron Digulla
It is a bug; I've reported it to Eclipse, and it's already been fixed in the HEAD. See the report here: https://bugs.eclipse.org/bugs/show_bug.cgi?id=142593
Paul Lammertsma
A: 

Try item.dispose() instead?

That's actually what I had before I tried fixing it with `table.remove(0)`. The bug was confirmed and fixed in the current SWT release.
Paul Lammertsma
A: 

Hello,

I see in the bugzilla, that the problem is solved. But the latest version, what I found was 2009.09.17. Can you tell me, where is the totally up2date version? It's reachable for all? Where can I find that?

Thanks, Gergely Bacso

Gergely Bacsó
It's not a release; you have to grab it from CVS. Instructions here: http://www.eclipse.org/swt/cvs.php
Paul Lammertsma