Bug 294974

Summary: [Viewers] Tool tips requested for items with unset data in virtual table
Product: [Eclipse Project] Platform Reporter: Eleanor Joslin <ejj-eclipsebugs>
Component: UIAssignee: Platform UI Triaged <platform-ui-triaged>
Status: NEW --- QA Contact:
Severity: normal    
Priority: P3 CC: emoffatt
Version: 4.0   
Target Milestone: ---   
Hardware: PC   
OS: Linux   
Whiteboard:

Description Eleanor Joslin CLA 2009-11-12 10:06:18 EST
User-Agent:       Mozilla/5.0 (X11; U; Linux i686; en-GB; rv:1.9.0.14) Gecko/2009090905 Fedora/3.0.14-1.fc10 Firefox/3.0.14
Build Identifier: I20090611-1540

After refreshing a virtual table with ~13,000 rows in my app, with the mouse hovering over the table, I sometimes see NPEs like this:

java.lang.NullPointerException
	at [my label provider].getToolTipText()
	at org.eclipse.jface.viewers.ColumnViewerToolTipSupport.shouldCreateToolTip(ColumnViewerToolTipSupport.java:163)
	at org.eclipse.jface.window.ToolTip.toolTipCreate(ToolTip.java:347)
	at org.eclipse.jface.window.ToolTip.access$2(ToolTip.java:346)
	at org.eclipse.jface.window.ToolTip$ToolTipOwnerControlListener.handleEvent(ToolTip.java:678)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1176)
	at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3493)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3112)
	at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2405)

The reason is that ColumnViewerToolTipSupport.shouldCreateToolTip() is passing a null element to the label provider.

From shouldCreateToolTip() (starting at line 145):

    Object element = row.getItem().getData();

    ViewerCell cell = row.getCell(point);

    // ... (lines that do not use element)

    String text = labelProvider.getToolTipText(element);

element is sometimes null, but after a SetData event sent during the call to TableViewerRow.getCell(Point) the correct data is set in the row's TableItem.  But since element has already been assigned by then, it's too late to pass the correct element to the label provider.

I think this could be fixed simply by swapping lines 145 and 147 round.

Reproducible: Sometimes
Comment 1 Bogdan Gheorghe CLA 2009-11-16 22:36:35 EST
Moving to Platform UI.
Comment 2 Hitesh CLA 2010-02-03 07:53:57 EST
A simple null check should fix this for good.

If the item is visible then the setData event would have been called already.
This should not happen under normal circumstances. But a strange *speculation* occurred to me, I am not sure about the various SWT details though. Consider the following running in a single runnable

1)Mouse has been still for a while ..
2)showItem/scroll/expand(programatically)
   [the setData events queued]
3)mouse hover event[ queued]
  [Is this possible given that the items are changing, the event occurring for Table/Tree though ?]
4)showItem/scroll/expand(programatically) again to new items
  [the *new* setData events queued]

The runnable finishes.

Mouse hover event processed before the *new* setData events from event queue. And, at the time of hover, mouse may be over the uninitialized items.

Or if showItem/scroll/expand was called from with another MouseTrackListener
This could be be a matter of order in which listeners are maintained internally.
I hope its not the case here.

Calling API such setText,getText,etc initializes the item, not getData.

Eric, any thougths on the above ?
Comment 3 Eclipse Webmaster CLA 2019-09-06 16:13:10 EDT
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.