-
Notifications
You must be signed in to change notification settings - Fork 135
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Destroy unused handles #1477
base: master
Are you sure you want to change the base?
Destroy unused handles #1477
Conversation
c0b5222
to
a81be93
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I only skimmed the code, I haven't tested it yet (I'll do it as soon as the PR is ready to be reviewed). I only have 2 minor remarks.
bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Device.java
Outdated
Show resolved
Hide resolved
bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/Resource.java
Show resolved
Hide resolved
a81be93
to
99f22f7
Compare
414cfe6
to
c639a59
Compare
This Contribution destroys those handles for the resources which were created for zoom levels which no monitor has anymore. The process is triggered on a DPI_CHANGED event. contributes to eclipse-platform#62 and eclipse-platform#127
c639a59
to
b728726
Compare
@@ -947,4 +953,24 @@ public void setWarnings (boolean warnings) { | |||
protected int getDeviceZoom () { | |||
return DPIUtil.mapDPIToZoom ( _getDPIx ()); | |||
} | |||
|
|||
void registerResource(Resource resource) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
void registerResource(Resource resource) { | |
void registerResourceWithZoomSupport(Resource r) { |
@@ -55,6 +58,7 @@ public abstract class Device implements Drawable { | |||
String[] loadedFonts; | |||
|
|||
volatile boolean disposed; | |||
private Vector<Resource> resources = new Vector<>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
private Vector<Resource> resources = new Vector<>(); | |
private Vector<Resource> resourcesWithZoomSupport = new Vector<>(); |
Also, why use Vector
and not Collection
/ List
? Do you need synchronization?
This PR contributes to the cleanup of those handles of Resources which were created for the zoom levels which are not applicable for the existing zoom levels of all the monitor. i.e., if there were 2 monitors with 100% and 200% zoom levels and the seconds monitor is switched to 100% as well. On the DPI_CHANGED event, we trigger a cleanup of handles of the resources using the resource tracker to remove the handles which were created for 200% zoom level since there doesn't exist any monitor with a zoom level of 100% anymore.
With this PR, we also refactor the resource tracker to allow it to track all the resources for win32 all the time but rather using the tracking flag to report errors, since that is the only use case of the tracking flag as of now. By allowing the Resource Tracker to track the resources, we can trigger the cleanup of all the relevant handles from a single point.
Contributes to #62 and #127