示例

public class ClassA {

private Shell shell;

public void makeShell( ) {

shell = new Shell( );

if ( !shell.isDisposed() ) {
//do something...
}
}
}



解决方案
为了避免资源泄漏,请确保对每个 org.eclipse.swt.widgets.Shell 都调用 dispose()。
注意:此规则适用于所有形式的 Shell 构造函数。


public class ClassA {

private Shell shell;

public void makeShell( ) {

shell = new Shell( );

if ( !shell.isDisposed() ) {
//do something...
}
shell.dispose();
}
}