Class Resource
- Direct Known Subclasses:
Color, Cursor, Font, GC, Image, Path, Pattern, Region, TextLayout, Transform
IMPORTANT: This class is intended to be subclassed only within the SWT implementation. However, it has not been marked final to allow those outside of the SWT development team to implement patched versions of the class in order to get around specific limitations in advance of when those limitations can be addressed by the team. Any class built using subclassing to access the internals of this class will likely fail to compile or run between releases and may be strongly platform specific. Subclassing should not be attempted without an intimate and detailed understanding of the workings of the hierarchy. No support is provided for user-written classes which are implemented as subclasses of this class.
- Since:
- 3.1
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static final classUsed to track not disposed SWT resource.private static final class -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate Cleaner.CleanableRepresents thetrackerregistered as a cleaning action via theResource.ResourceTracker.cleaner(package private) Devicethe device where this resource was createdUsed to report not disposed SWT resources, null by defaultprivate Resource.ResourceTrackerUsed to track not disposed SWT resource -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) voiddestroy()(package private) voiddestroyHandlesExcept(Set<Integer> zoomLevels) Destroy all handles of the resource which are not necessary for the given zoom levels.voiddispose()Disposes of the operating system resources associated with this resource.Returns theDevicewhere this resource was created.(package private) void(package private) voidinit()(package private) voidabstract booleanReturnstrueif the resource has been disposed, andfalseotherwise.static voidsetNonDisposeHandler(Consumer<Error> reporter) Enables detection of Resource objects for whichdispose()wasn't called, which means a leak of native memory and/or OS resources.
-
Field Details
-
device
Device devicethe device where this resource was created -
nonDisposedReporter
-
tracker
Used to track not disposed SWT resource -
cleanable
Represents thetrackerregistered as a cleaning action via theResource.ResourceTracker.cleaner
-
-
Constructor Details
-
Resource
public Resource() -
Resource
Resource(Device device)
-
-
Method Details
-
destroy
void destroy() -
destroyHandlesExcept
Destroy all handles of the resource which are not necessary for the given zoom levels. This method is supposed to be overridden by sub-classes that retain handles for different zoom levels.- Parameters:
zoomLevels- The zoom levels for which the handles are supposed to be retained.
-
dispose
public void dispose()Disposes of the operating system resources associated with this resource. Applications must dispose of all resources which they allocate. This method does nothing if the resource is already disposed. -
getDevice
Returns theDevicewhere this resource was created.- Returns:
Devicethe device of the receiver- Since:
- 3.2
-
ignoreNonDisposed
void ignoreNonDisposed() -
init
void init() -
initNonDisposeTracking
void initNonDisposeTracking() -
isDisposed
public abstract boolean isDisposed()Returnstrueif the resource has been disposed, andfalseotherwise.This method gets the dispose state for the resource. When a resource has been disposed, it is an error to invoke any other method (except
dispose()) using the resource.- Returns:
truewhen the resource is disposed andfalseotherwise
-
setNonDisposeHandler
Enables detection of Resource objects for whichdispose()wasn't called, which means a leak of native memory and/or OS resources. WARNING: the reporter will be called from a different thread. Do not block it and do not throw any exceptions. It's best to queue the errors for some other worker to process.- Parameters:
reporter- object used to report detected errors. Use null to disable tracking. Setting a new reporter has an immediate effect.- Since:
- 3.116
-