Skip to content

[win32] Wrapper for existing image handles #2027

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

Conversation

akoch-yatta
Copy link
Contributor

This PR adds a wrapper for images created with an existing OS handle to ensure all existing image constructors are tied to a final wrapper instance.

Copy link
Contributor

github-actions bot commented Apr 16, 2025

Test Results

   545 files  ±0     545 suites  ±0   32m 55s ⏱️ - 1m 14s
 4 373 tests ±0   4 361 ✅ ±0   12 💤 ±0  0 ❌ ±0 
16 634 runs  ±0  16 520 ✅ ±0  114 💤 ±0  0 ❌ ±0 

Results for commit 478c83f. ± Comparison against base commit 6517c9e.

♻️ This comment has been updated with latest results.

Copy link
Contributor

@HeikoKlare HeikoKlare left a comment

Choose a reason for hiding this comment

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

In general, the change looks sound to me. I was wondering if we can avoid creating a new type of provider by just using the image data of the given handle, but if I am not mistaken that's not possible (or not a good idea at least), because the current implementation allows to share handles between Image instances, which is also why disposed resource tracking is not instantiated for an Image created via an existing handle. Is that correct?

This kind of change seems to allow for more cleanups. The follow methods have implementations for imageProvider == null, which should become obsolete by this change and can be removed, can't they?

  • equals / hashCode
  • getBounds
  • getImageData
  • getImageMetaData (see detailled comment)

} else {
ImageData resizedData = getImageData(zoom);
ImageData newData = adaptImageDataIfDisabledOrGray(resizedData);
init(newData, zoom);
Copy link
Contributor

Choose a reason for hiding this comment

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

In the Image#getImageMetadata(int) method, there is a special initialization handling for the case that the image is an icon. What if the image created with this new provider is such an icon-type image, won't the initialization potentially lead to wrong results?
Or even more: the imageProvider == null case in the Image#getImageMetadata(int) method should become completely obsolete by this change, so it should be removed and there and completely be moved into this method, shouldn't it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm, regarding the first point. probably yes, but isn't this an issue with e.g. MaskedImageDataProviderWrapper as well?
Second point. Yes, question to me is, when and how do we do the cleanup.

Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm, regarding the first point. probably yes, but isn't this an issue with e.g. MaskedImageDataProviderWrapper as well?

Probably, yes. We should check again the original issue that was fixed by that special handling for icon to see if we can reproduce the issue now.

Second point. Yes, question to me is, when and how do we do the cleanup.

Okay, let's do that as a follow-up. But I would do that now (and before #1996) if possible.

@akoch-yatta
Copy link
Contributor Author

In general, the change looks sound to me. I was wondering if we can avoid creating a new type of provider by just using the image data of the given handle, but if I am not mistaken that's not possible (or not a good idea at least), because the current implementation allows to share handles between Image instances, which is also why disposed resource tracking is not instantiated for an Image created via an existing handle. Is that correct?

Yes, we definitely need to use the passed OS handle, because it is created outside of the control of the Image. Therefor I did not see another approach as creating a separate wrapper for it

This kind of change seems to allow for more cleanups. The follow methods have implementations for imageProvider == null, which should become obsolete by this change and can be removed, can't they?

  • equals / hashCode
  • getBounds
  • getImageData
  • getImageMetaData (see detailled comment)

Yes, but I wanted to do that cleanup separately.

@akoch-yatta akoch-yatta force-pushed the win32-wrapper-with-existing-image-handle branch from 38b8c42 to ab19dd0 Compare April 17, 2025 13:47
@akoch-yatta akoch-yatta force-pushed the win32-wrapper-with-existing-image-handle branch from ab19dd0 to 3dad941 Compare April 17, 2025 18:32
This commit adds a wrapper for images created with an existing OS handle
to ensure all existing image constructors are tied to a final wrapper
instance.
@HeikoKlare HeikoKlare force-pushed the win32-wrapper-with-existing-image-handle branch from 3dad941 to 478c83f Compare April 22, 2025 15:29
@HeikoKlare
Copy link
Contributor

Merging this despite Jenkins failure caused by https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/issues/5892

Since master builds seem to still work on Jenkins, the subsequent master build should hopefully work, thus I will check results of that build to retrospectively validate this PR.

@HeikoKlare HeikoKlare merged commit ad0aa6b into eclipse-platform:master Apr 23, 2025
10 of 12 checks passed
@HeikoKlare HeikoKlare deleted the win32-wrapper-with-existing-image-handle branch April 23, 2025 06:12
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