Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 325758

Summary: Reentrant call in ColumnViewer when setting selection on a TableViewer
Product: [Eclipse Project] Platform Reporter: Tim Moore <tmm-bugs.eclipse>
Component: SWTAssignee: Platform-SWT-Inbox <platform-swt-inbox>
Status: CLOSED WONTFIX QA Contact:
Severity: normal    
Priority: P3 CC: adietish, eclipse.felipe, ejj-eclipsebugs, hsoliwal
Version: 4.0   
Target Milestone: ---   
Hardware: PC   
OS: All   
Whiteboard: stalebug
Attachments:
Description Flags
Test Case none

Description Tim Moore CLA 2010-09-20 10:12:32 EDT
Build Identifier: I20100608-0911

Run the attached test case. Observe that testEmptyFirstLabelCausesReentrantCall causes the "Ignored reentrant call while viewer is busy." [1] message to be logged.

Not seen on Windows.

[1]
!ENTRY org.eclipse.jface 2 0 2010-09-20 15:08:18.889
!MESSAGE Ignored reentrant call while viewer is busy. This is only logged once per viewer instance, but similar calls will still be ignored.
!STACK 0
java.lang.RuntimeException
	at org.eclipse.jface.viewers.ColumnViewer.checkBusy(ColumnViewer.java:763)
	at org.eclipse.jface.viewers.AbstractTableViewer.replace(AbstractTableViewer.java:1056)
	at TestVirtualTableViewerSetSelectionReentrantCall$SimpleLazyTableContentProvider.updateElement(TestVirtualTableViewerSetSelectionReentrantCall.java:38)
	at org.eclipse.jface.viewers.AbstractTableViewer$1.handleEvent(AbstractTableViewer.java:86)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1258)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1282)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1267)
	at org.eclipse.swt.widgets.Table.checkData(Table.java:286)
	at org.eclipse.swt.widgets.TableItem.getImage(TableItem.java:531)
	at org.eclipse.jface.viewers.TableViewerRow.setImage(TableViewerRow.java:132)
	at org.eclipse.jface.viewers.ViewerCell.setImage(ViewerCell.java:169)
	at org.eclipse.jface.viewers.ColumnLabelProvider.update(ColumnLabelProvider.java:38)
	at org.eclipse.jface.viewers.ViewerColumn.refresh(ViewerColumn.java:152)
	at org.eclipse.jface.viewers.AbstractTableViewer.doUpdateItem(AbstractTableViewer.java:399)
	at org.eclipse.jface.viewers.StructuredViewer$UpdateItemSafeRunnable.run(StructuredViewer.java:481)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
	at org.eclipse.ui.internal.JFaceUtil$1.run(JFaceUtil.java:49)
	at org.eclipse.jface.util.SafeRunnable.run(SafeRunnable.java:175)
	at org.eclipse.jface.viewers.StructuredViewer.refreshItem(StructuredViewer.java:1533)
	at org.eclipse.jface.viewers.AbstractTableViewer.replace(AbstractTableViewer.java:1059)
	at TestVirtualTableViewerSetSelectionReentrantCall$SimpleLazyTableContentProvider.updateElement(TestVirtualTableViewerSetSelectionReentrantCall.java:38)
	at org.eclipse.jface.viewers.AbstractTableViewer.virtualSetSelectionToWidget(AbstractTableViewer.java:975)
	at org.eclipse.jface.viewers.AbstractTableViewer.setSelectionToWidget(AbstractTableViewer.java:885)
	at org.eclipse.jface.viewers.StructuredViewer.setSelectionToWidget(StructuredViewer.java:1741)
	at org.eclipse.jface.viewers.StructuredViewer.setSelection(StructuredViewer.java:1697)
	at org.eclipse.jface.viewers.TableViewer.setSelection(TableViewer.java:158)
	at org.eclipse.jface.viewers.Viewer.setSelection(Viewer.java:392)
	at TestVirtualTableViewerSetSelectionReentrantCall.createTableViewerAndSelectFirstRow(TestVirtualTableViewerSetSelectionReentrantCall.java:113)
	at TestVirtualTableViewerSetSelectionReentrantCall.testEmptyFirstLabelCausesReentrantCall(TestVirtualTableViewerSetSelectionReentrantCall.java:69)

Reproducible: Always
Comment 1 Tim Moore CLA 2010-09-20 10:13:33 EDT
Created attachment 179246 [details]
Test Case
Comment 2 Tim Moore CLA 2010-09-20 10:18:18 EDT
A little more information: it appears that when the text is empty for a new TableItem then TableItem.setText(...) is a no-op and returns early, without fully initializing and setting the "cached" field. It appears the other setters, or at least TableItem.setImage(...), cannot proceed without this method having completed normally.
Comment 3 Tim Moore CLA 2010-10-15 07:02:36 EDT
Actually the test case does fail on Windows(7). I don't know why I thought otherwise at the time.
Comment 4 Felipe Heidrich CLA 2010-10-15 10:14:16 EDT
Bug in JFace ?
Comment 5 Hitesh CLA 2010-10-18 10:05:07 EDT
(In reply to comment #4)
> Bug in JFace ?

Nope!! There seems to be a difference in how SWT handles setText for first column as opposed to others.

In method TableItem#setText (int, String) the following two snippets make the difference

	if (index == 0) {
		if (string.equals (text)) return;
		super.setText (string);
	}

And

	if ((parent.style & SWT.VIRTUAL) != 0) cached = true; 
	//not called when index = 0 & same text
Comment 6 Felipe Heidrich CLA 2010-10-19 12:16:51 EDT
(In reply to comment #5)
> In method TableItem#setText (int, String) the following two snippets make the
> difference
>     if (index == 0) {
>         if (string.equals (text)) return;
>         super.setText (string);
>     }
> And
>     if ((parent.style & SWT.VIRTUAL) != 0) cached = true; 
>     //not called when index = 0 & same text

Keep reading the code:

	if (strings != null) {
		if (string.equals (strings [index])) return;
		strings [index] = string;
	}

It means "cached = true;" will not happen when calling setText() with the same text. Consistent for all columns I'd expect.

If the problem is in SWT, please provide a SWT only snippet that shows it. Thank you.
Comment 7 Hitesh CLA 2010-10-19 15:00:31 EDT
(In reply to comment #6)

The attached Test case  clearly & sufficiently demonstrates the problem on my machine - can you observe the same on your machine ? And, the difference lies around the highlighted SWT code. 

> 
> Keep reading the code:
> 

Sure, I can look at it further when I have spare time - same for snippet :)
Comment 8 Eclipse Genie CLA 2020-04-01 14:00:53 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. 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.