The app is an Eclipse 3.6 based RCP (so jface version 3.5.2) running on windows 7.
I have a custom View class that contains a TableViewer
and calls refresh()
on it. Sometimes, but not very often it results in the stack trace below. It's called from within the UI thread. I suspected the problem was with other code that changes the backing list to the table, but that any code that does this is also run in either a syncExec or asyncExec method so I don't understand how it could be a synchronisation issue between the changing of table items and the refresh of the viewer.
Any ideas what i can do to prevent this happening?
!ENTRY org.eclipse.jface 4 2 2010-10-20 09:22:06.140 !MESSAGE Problems occurred when invoking code from plug-in: "org.eclipse.jface". !STACK 0 org.eclipse.swt.SWTException: Widget is disposed
at org.eclipse.swt.SWT.error(SWT.java:3884) at org.eclipse.swt.SWT.error(SWT.java:3799)
at org.eclipse.swt.SWT.error(SWT.java:3770) at org.eclipse.swt.widgets.Widget.error(Widget.java:463)
at org.eclipse.swt.widgets.Widget.checkWidget(Widget.java:336)
at org.eclipse.swt.widgets.Widget.getData(Widget.java:521)
at org.eclipse.jface.viewers.AbstractTableViewer.setSelectionToWidget(AbstractTableViewer.java:921)
at org.eclipse.jface.viewers.StructuredViewer.setSelectionToWidget(StructuredViewer.java:1711)
at org.eclipse.jface.viewers.StructuredViewer.preservingSelection(StructuredViewer.java:1399)
at org.eclipse.jface.viewers.StructuredViewer.preservingSelection(StructuredViewer.java:1353)
at org.eclipse.jface.viewers.StructuredViewer.refresh(StructuredViewer.java:1455)
at org.eclipse.jface.viewers.ColumnViewer.refresh(ColumnViewer.java:537)
at org.eclipse.jface.viewers.StructuredViewer.refresh(StructuredViewer.java:1414)
...
at org.eclipse.swt.widgets.Synchronizer.syncExec(Synchronizer.java:179)
Seems like refresh() method is called after the viewer is disposed (closed?). You can avoid this exception by checking:
public void refresh() {
if (viewer != null && !viewer.getControl().isDisposed()) {
// Actual refresh code
}
}