[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [platform-swt-dev] Inconsistent need of disposal of resources not directly allocated by client
- From: Stephan Aßmus <superstippi@xxxxxx>
- Date: Thu, 29 Sep 2011 16:40:02 +0200
- Delivered-to: email@example.com
- User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:184.108.40.206) Gecko/20110831 Thunderbird/3.1.13
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,