[Nebula Gallery] The best way to dispose of items [message #783303] |
Wed, 25 January 2012 08:15  |
Eclipse User |
|
|
|
Hi All,
What is the best way to dispose of items of a virtual Gallery?
I save an object in the data field of each gallery item. for instance a
SWT.SetData listener:
public void handleEvent(Event event) {
GalleryItem item = (GalleryItem) event.item;
GalleryItem parent = item.getParentItem();
//!!!
item.setData(getObject(item));
if (parent == null) {
// group
processGroup(item, event.index);
} else {
// regular item
processItem(item, event.index);
}
}
How do I know when the item is disposed to clear my object. I tried
using item.addDisposeListener(...); and it was never called. And
Gallery.removeAll() and Gallery.remove(int) seem to behave differently:
remove(int) doesn't seem to call dispose() for an item.
Best regards,
Ivan
|
|
|
|
|
|
Re: [Nebula Gallery] The best way to dispose of items [message #791786 is a reply to message #787523] |
Mon, 06 February 2012 03:59  |
Eclipse User |
|
|
|
Hi Nicolas,
Thanks, I will try this.
On 31.01.2012 19:17, Nicolas RICHETON wrote:
> Hi Ivan
>
> Gallery should behave exactly as Tree or Table. Try to replace Gallery
> and GalleryItem by Tree and TreeItem. If this works with Tree, then this
> is a Gallery bug. If not this is how swt works. There is a unit test
> which ensure that Gallery and Tree uses the same API. You can add some
> more tests to show the differences you found and submit a patch.
>
> Btw if I remember correctly, listening to dispose is not the right way
> to release ressources since It may not be called or not in the order you
> expect because it is os-dependent.
>
> Nicolas
|
|
|
Powered by
FUDForum. Page generated in 0.04460 seconds