[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[platform-swt-dev] Inconsistent need of disposal of resources not directly allocated by client
|
Hello SWT team,
thank you for such a great framework!
I know that I am supposed to call dispose() on any resources such as
Fonts, Colors and Images, which I allocate myself.
Something that I find very troublesome in the API, and which you may
want to consider cleaning up and making consistent, is that it is not at
all clear when functions that return such resources have actually
allocated new copies. By pure coincidence, I have looked at the
implementation of Control.getBackground() and saw that it actually
returns a new Color which I am supposed to dispose().
The seemingly similar Control.getFont() however returns a Font which is
either the direct member of the Control, or the global system font of
the Display, both of which shall not be disposed, of course.
Maybe I am missing something, but this should really get documented
properly, or better yet, be made consistent (but I suppose it's
impossible, since existing applications would stop working correctly).
Since all those resources can actually not be modified, it would have
been most convenient for clients, if such resources were never supposed
to be freed.
Best regards,
-Stephan