Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [platform-swt-dev] Inconsistent need of disposal of resources not directly allocated by client

Hi,

On 29.09.2011 16:34, Grant Gayed wrote:
SWT API like Control.getBackground() does not allocate a new native
resource that needs to be dispose()d by the caller (the
Color.win32_new() javadoc could be misinterpreted to imply otherwise).
Such implementations may return a new Color object that wraps the native
resource, but a new native resource is not allocated. You should never
dispose() a graphic resource unless you originally created it with "new
...". I think that you can get away with over-dispose()ing a Color on
win32 due to an implementation detail, but doing this on other platforms
or with other types of graphics resources will cause problems.

Thanks for clearing this up so fast! I actually looked at the GTK implementation, which calls a similarily named method, but I am relieved that this stuff is consistently not supposed to be disposed. I will fix my code where I am already over-disposing.

Thanks again & best regards,
-Stephan


Back to the top