Closed thomasa299792 closed 2 months ago
The GC might not be disposed in MaxCellBounds.getPreferredRowHeights() if the method exits due to an exception.
MaxCellBounds.getPreferredRowHeights()
That exception might have been https://github.com/eclipse-nattable/nattable/issues/93 .
Observed in v2.0.5 with an SWT non-dispose handler set by Resource.setNonDisposeHandler( ... ).
Resource.setNonDisposeHandler( ... )
Current code:
GC gc = gcFactory.createGC(); if (gc != null) { int[] rowHeights = new int[rowPositions.length]; for (int i = 0; i < rowPositions.length; i++) { rowHeights[i] = getPreferredRowHeight(layer, rowPositions[i], configRegistry, gc); } gc.dispose(); ...
One possible fix:
GC gc = gcFactory.createGC(); if (gc != null) { int[] rowHeights = new int[rowPositions.length]; try { for (int i = 0; i < rowPositions.length; i++) { rowHeights[i] = getPreferredRowHeight(layer, rowPositions[i], configRegistry, gc); } } finally { gc.dispose(); }
Changed the issue title as I noticed other places where the try...finally was also missing.
try...finally
The GC might not be disposed in
MaxCellBounds.getPreferredRowHeights()
if the method exits due to an exception.That exception might have been https://github.com/eclipse-nattable/nattable/issues/93 .
Observed in v2.0.5 with an SWT non-dispose handler set by
Resource.setNonDisposeHandler( ... )
.Current code:
One possible fix: