Skip to content
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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

amartya4256
Copy link
Contributor

@amartya4256 amartya4256 commented Sep 19, 2024

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

Copy link
Contributor

github-actions bot commented Sep 19, 2024

Test Results

   486 files  ±0     486 suites  ±0   7m 20s ⏱️ -59s
 4 159 tests ±0   4 151 ✅ ±0   8 💤 ±0  0 ❌ ±0 
16 390 runs  ±0  16 298 ✅ ±0  92 💤 ±0  0 ❌ ±0 

Results for commit b728726. ± Comparison against base commit ebe6ec4.

♻️ This comment has been updated with latest results.

@amartya4256 amartya4256 force-pushed the destroy_handles branch 6 times, most recently from c0b5222 to a81be93 Compare September 24, 2024 09:13
Copy link
Contributor

@fedejeanne fedejeanne left a 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.

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
@@ -947,4 +953,24 @@ public void setWarnings (boolean warnings) {
protected int getDeviceZoom () {
return DPIUtil.mapDPIToZoom ( _getDPIx ());
}

void registerResource(Resource resource) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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<>();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
private Vector<Resource> resources = new Vector<>();
private Vector<Resource> resourcesWithZoomSupport = new Vector<>();

Also, why use Vector and not Collection / List? Do you need synchronization?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants