Przykład
public class
ClassA {
private
TextLayout textLayout;
public void
makeTextLayout( Device device ) {
textLayout =
new
TextLayout( device );
if ( !textLayout.isDisposed() ) {
//inne operacje...
}
}
}
Rozwiązanie
Aby uniknąć przecieków zasobów, upewnij się, że dla każdej klasy org.eclipse.swt.graphics.TextLayout jest wywoływana metoda dispose().
public class
ClassA {
private
TextLayout textLayout;
public void
makeTextLayout( Device device ) {
textLayout =
new
TextLayout( device );
if ( !textLayout.isDisposed() ) {
//inne operacje...
}
textLayout.dispose();
}
}