| Summary: | ArrayIndexOutOfBoundsException on TableItem.fontHandle | ||
|---|---|---|---|
| Product: | [Eclipse Project] Platform | Reporter: | Willem Duminy <willem.duminy> |
| Component: | SWT | Assignee: | Platform-SWT-Inbox <platform-swt-inbox> |
| Status: | CLOSED WONTFIX | QA Contact: | |
| Severity: | normal | ||
| Priority: | P3 | CC: | craighewetson, eclipse.felipe |
| Version: | 4.1 | ||
| Target Milestone: | --- | ||
| Hardware: | PC | ||
| OS: | Windows Vista | ||
| Whiteboard: | stalebug | ||
|
Description
Willem Duminy
I get this error too often. Look at the code in "org.eclipse.swt.widgets.Table.wmNotifyToolTip" It seems that the windows call OS.LVM_SUBITEMHITTEST sometimes places a -1 in "iSubItem" which is used to determine the font. If the logic changes to accept tha a -1 in this field is possible, things should be fine. i.e code at line 151 now reads --- int /*long*/ hFont = item.fontHandle (pinfo.iSubItem); if (hFont != -1) hFont = OS.SelectObject (hDC, hFont); --- Maybe it should be changed to: --- int /*long*/ hFont = -1 if (pinfo.iSubItem != -1) hFont = item.fontHandle (pinfo.iSubItem); if (hFont != -1) hFont = OS.SelectObject (hDC, hFont); --- (In reply to comment #1) > Maybe it should be changed to: > --- > int /*long*/ hFont = -1 > if (pinfo.iSubItem != -1) hFont = item.fontHandle (pinfo.iSubItem); > if (hFont != -1) hFont = OS.SelectObject (hDC, hFont); > --- First I'd like to know why is the OS returning -1 in pinfo.iSubItem ? Is the value in pinfo.iItem correct ? What it is ? Is there other invalid values happening for pinfo.iSubItem. (i.e -4) ? Note that your fix is not complete, pinfo.iSubItem is used in other places in the same method and it would cause problems elsewhere. The best fix is probably to return without doing any work when pinfo.iSubItem==-1, but first we should try to know why it this is happening. Can't we use the proposed patch and therefore solve effects of this bug and then create a new case that will address the deeper cause of the problem? (In reply to comment #3) > Can't we use the proposed patch and therefore solve effects of this bug and > then create a new case that will address the deeper cause of the problem? Rather not, I still don't understand why the problem happens and I'm not sure the patch is correct. I think it is premature to release any code at this point. Unfortunately the problem doesn't happen to me (I tried), so it is hard for me work on this problem. Can you guys add this code in and self host eclipse for debugging: Table#wmNotifyToolTip line 7102. TableItem item = _getItem (pinfo.iItem); if (pinfo.iSubItem != -1) { System.out.println(pinfo.iItem + " columnCount="+getColumnCount() + " itemCount="+getItemCount() + " style="+getStyle()); System.out.println("pt " + pt.x + ", " + pt.y); for (int i = 0; i < getColumnCount(); i++) { System.out.println(i +"="+item.getBounds(i)); } } int /*long*/ hDC = OS.GetDC (handle); Here is the snippet I was trying with: public static void main2(String[] args) { Display display = new Display(); final Shell shell = new Shell(display); shell.setLayout(new FillLayout()); Table table = new Table (shell, SWT.NONE); TableItem item = new TableItem(table, SWT.FULL_SELECTION); TableColumn c = new TableColumn(table, 0); c.setWidth(100); c = new TableColumn(table, 0); c.setWidth(100); item.setText("Item longer text for native tooltip"); item.setText(1, "the other column with long text"); table.setHeaderVisible(true); table.addListener(SWT.PaintItem, new Listener() { public void handleEvent(Event event) { } }); table.addListener(SWT.MeasureItem, new Listener() { public void handleEvent(Event event) { } }); shell.pack(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); } Never saw isubItem==-1 This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant. This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. As such, we're closing this bug. If you have further information on the current state of the bug, please add it and reopen this bug. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant. -- The automated Eclipse Genie. |