Community
Participate
Working Groups
Tools like Sleak could better be written by having a callback during Device.new_Object and Device.dispose_Object.
Created attachment 58942 [details] Patch to add resource callbacks
If you want to reuse the Listener interface, the pattern would suggest defining new event types. e.g. SWT.ResourceAllocated, SWT.ResourceDisposed. Another option might be to move the tracking code (Device#new_Object, dispose_Object) into the DeviceData class, and allowing DeviceData to be extended with the usual "not intended to be subclassed" warning.
I think defining new event types is the way to go. I 'appropriated' a couple for my patch since I was trying to minimize my changes. I also like Randy's suggestion of moving the tracking code to DeviceData since it seems like a debug only class.
Created attachment 59072 [details] Better patch with new SWT event types Added ResourceAllocated/ResourceDisposed SWT event types. Wrapped the listener in a try/finally to guard against bad listeners.
Unfortunately we can't use the patch as-is, because we don't want to reference the widgets package from the graphics package. We have gone to great lengths to ensure that the graphics package remains completely stand-alone. However, we are looking at alternatives that will still achieve your objective. Stand by...
FYI, we are looking at a general solution for notifying when resources are created or deleted. We want to track widgets as resources also. And we want this new solution to be compatible with the current resource tracking mechanism. It's going to be a lot of changes and we have not finalized our thinking, so we will not have this solution today... in case you were hoping for something in time for EclipseCon. :(
That's fine. It would have been nice to have for EclipseCon, but as long as it makes it in for 3.3 I'll be tickled pink.
Sorry but it won't be making it. We're into 3.3 M6 API freeze and won't get to this.
With 3.3 out the door and 3.4 planning started (or finished, not sure) I wanted to bring up this feature request again. As a reminder, the feature request is to add resource and widget create/dispose callbacks to device. This would make building tools like Sleak much easier and wouldn't require changes to SWT (after this one of course :-) ) Steve and I spoke about this at EclipseCon - if I recall correctly, Steve was concerned about the "boil the ocean" nature of this change and the API issue. Anything I can do to help push this along? Is now a good time to make this change?
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.