Eclipse RAP:" dispose"的最佳实践小部件?

时间:2015-07-31 18:10:35

标签: swt eclipse-rcp eclipse-rap

我是Eclipse RAP的新手,没有使用SWT或Eclipse RCP的经验。但据我所知,开发人员负责处理SWT小部件,因为他们有本地对等方可能会阻止操作系统的资源。

但是"处理"在RAP应用程序中?管理操作系统资源是一个浏览器的问题(可能是文件对话框)。所以"处理"对于纯RAP的应用程序来说似乎没必要,对吗?

现在,如果我想使用SWT和RWT 进行单一来源,即相同的源代码作为独立的RCP应用程序和RAP Web应用程序运行。 关于"处置"最佳做法是什么?如何触发?需要处理什么?

2 个答案:

答案 0 :(得分:2)

There is no difference between SWT and SWT/RAP when it comes to disposing of widgets.

While SWT widgets hold native OS/window system resources while not disposed, RAP widgets hold browser resources i.e. DOM nodes as long as they live. Dispose of widgets when they are no longer needed and create widgets lazily if possible.

答案 1 :(得分:1)

关于需要处理的内容 - 任何使用dispose方法的内容!这是从WidgetResource

派生的任何内容

处理从Widget(控件,复合材料......)派生的对象通常在Shell关闭时自动处理。

处理来自Resource的对象(ColorGCFont,...等)必须由您的代码完成。您应该在不再需要它们时立即将其丢弃。未能处理这些物体是一个常见的错误。