org.eclipse.swt.SWTException:“Widget被释放”从表刷新 [英] org.eclipse.swt.SWTException: "Widget is disposed" from table refresh
问题描述
该应用程序是在Windows 7上运行的基于Eclipse 3.6的RCP(所以jface版本3.5.2)。
The app is an Eclipse 3.6 based RCP (so jface version 3.5.2) running on windows 7.
我有一个包含<$的自定义View类c $ c> TableViewer 并在其上调用 refresh()
。有时,但不是经常导致下面的堆栈跟踪。它是从UI线程中调用的。我怀疑问题是其他代码将支持列表更改为表,但执行此操作的任何代码也在syncExec或asyncExec方法中运行,所以我不明白它是如何在更改之间的同步问题表项和刷新查看器。
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)
推荐答案
似乎在查看器被处理(关闭?)之后调用了refresh()方法。您可以通过检查来避免此异常:
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
}
}
这篇关于org.eclipse.swt.SWTException:“Widget被释放”从表刷新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!