简体   繁体   English

org.eclipse.swt.SWTException:从表刷新中“处理小部件”

[英]org.eclipse.swt.SWTException: “Widget is disposed” from table refresh

The app is an Eclipse 3.6 based RCP (so jface version 3.5.2) running on windows 7. 该应用程序是基于Eclipse 3.6的RCP(因此jface版本3.5.2)在Windows 7上运行。

I have a custom View class that contains a TableViewer and calls refresh() on it. 我有一个包含TableViewer的自定义View类,并在其上调用refresh() Sometimes, but not very often it results in the stack trace below. 有时,但不是经常导致下面的堆栈跟踪。 It's called from within the UI thread. 它是从UI线程中调用的。 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. 我怀疑问题是其他代码将支持列表更改为表,但执行此操作的任何代码也在syncExec或asyncExec方法中运行,所以我不明白它是如何在更改之间的同步问题表项和刷新查看器。

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?). 看起来像refresh()方法是在查看器被释放后调用的(关闭?)。 You can avoid this exception by checking: 您可以通过检查来避免此异常:

public void refresh() {
   if (viewer != null && !viewer.getControl().isDisposed()) {
      // Actual refresh code
   }
}

Try use display.isDisposed() like this. 尝试像这样使用display.isDisposed()。

    shell.getDisplay().asyncExec(new Runnable()
    {
        @Override
        public void run ()
        {
            if(!display.isDisposed() && !disposing)
            {
                              //you source code
            }
        }
    });

But remember that isDisposed() return true then disposing end. 但请记住isDisposed()返回true然后处理结束。 Thats why you shod use flag 这就是为什么你穿旗子

disposing = true; disposing = true;

display.dispose(); display.dispose();

disposing = false; disposing = false;

Just create a new work-space. 只需创建一个新的工作空间。 Import your projects. 导入您的项目。 It worked for me. 它对我有用。 :) :)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 org.eclipse.swt.SWTException:从表中删除多行时会丢弃小部件-SWT - org.eclipse.swt.SWTException: Widget is disposed when removing multiple rows from table - SWT org.eclipse.swt.SWTException:尝试打开 AndroidManifest.xml 时出现“小部件已处理” - org.eclipse.swt.SWTException: “Widget is disposed” when trying to open AndroidManifest.xml org.eclipse.swt.SWTException: 无法执行 runnable - org.eclipse.swt.SWTException: Failed to execute runnable org.eclipse.swt.SWTException:无效的线程访问 - org.eclipse.swt.SWTException: Invalid thread access org.eclipse.swt.SWTException:不支持的颜色深度 - org.eclipse.swt.SWTException: Unsupported color depth 运行jar时的SWT异常:线程“main”中的异常org.eclipse.swt.SWTException:无效的线程访问 - SWT Exception when running jar: Exception in thread “main” org.eclipse.swt.SWTException: Invalid thread access org.eclipse.swt.SWTException:执行功能时Eclipse Graphiti中的图形 - org.eclipse.swt.SWTException: Graphic in Eclipse Graphiti when executing feature 从Eclipse RCP 3.x升级到4.x:org.eclipse.e4.core.di.InjectionException:org.eclipse.swt.SWTException:无效的线程访问 - Upgraded from Eclipse RCP 3.x to 4.x: org.eclipse.e4.core.di.InjectionException: org.eclipse.swt.SWTException: Invalid thread access org.eclipse.swt.SWTException:无法执行可运行(java.lang.NullPointerException) - org.eclipse.swt.SWTException: Failed to execute runnable (java.lang.NullPointerException) SWT TreeViewer拖移n放下:放置SWTException小部件 - SWT TreeViewer Drag n Drop: SWTException Widget is disposed
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM