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

Fix: Unable to open Advanced Search Dialog more than once #1367

Merged
merged 1 commit into from
Aug 6, 2024

Conversation

ptziegler
Copy link
Contributor

When opening this dialog, the tab items are decorated with images created by the individual search panels. When the dialog is closed, those images are disposed again.

Problem arises because the search panels don't create new images, but instead use shared images. Meaning when the dialog is opened a second time, those images have already been disposed, preventing the dialog from showing up.

Reason for this regression is the switch from the Icons class of the bndtools project to the PDE Resources class. Former has an explicit "isDisposed()" check, which would've created a new image on-the-fly, while latter doesn't. Given that the images are not owned by this dialog, the solution to this problem is to simply not have them be disposed by the dialog.

See #1365

@ptziegler
Copy link
Contributor Author

This is the original code that was used to create those images. The "isDisposed()" check is what prevents this problem from showing up with the bndtools.:

public static Image image(String name, String... decorators) {
	synchronized (images) {
		Key k = new Key(name, decorators);
		Image image = images.get(k);
		if (image != null && !image.isDisposed())
			return image;


		if (decorators.length == 0) {
			ImageDescriptor desc = desc(name, false);
			if (desc == null) {
				desc = desc(ICONS_MISSING_GIF);
			}
			Image baseImage = desc.createImage();
			images.put(k, baseImage);
			return baseImage;
		}


		Image baseImage = image(name);


		ImageDescriptor overlays[] = new ImageDescriptor[decorators.length];
		for (int i = 0; i < decorators.length; i++) {
			overlays[i] = desc(decorators[i], true);
		}
		DecorationOverlayIcon decoratedImage = new DecorationOverlayIcon(baseImage, overlays);
		Image result = decoratedImage.createImage();
		images.put(k, result);
		return result;
	}
}

Copy link

github-actions bot commented Aug 6, 2024

Test Results

   285 files  ±0     285 suites  ±0   48m 23s ⏱️ - 2m 22s
 3 580 tests ±0   3 502 ✅  - 2   76 💤 ±0  0 ❌ ±0  2 🔥 +2 
10 932 runs  ±0  10 699 ✅  - 2  231 💤 ±0  0 ❌ ±0  2 🔥 +2 

For more details on these errors, see this check.

Results for commit 1452454. ± Comparison against base commit 8f742cd.

♻️ This comment has been updated with latest results.

When opening this dialog, the tab items are decorated with images
created by the individual search panels. When the dialog is closed,
those images are disposed again.

Problem arises because the search panels don't create new images, but
instead use shared images. Meaning when the dialog is opened a second
time, those images have already been disposed, preventing the dialog
from showing up.

Reason for this regression is the switch from the Icons class of the
bndtools project to the PDE Resources class. Former has an explicit
"isDisposed()" check, which would've created a new image on-the-fly,
while latter doesn't. Given that the images are not owned by this
dialog, the solution to this problem is to simply not have them be
disposed by the dialog.

See eclipse-pde#1365
Copy link
Member

@HannesWell HannesWell left a comment

Choose a reason for hiding this comment

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

That's a good catch and nice investigation. 👍🏽

Thank you.

Test failure is unrelated.

@HannesWell HannesWell merged commit 90a3dc1 into eclipse-pde:master Aug 6, 2024
15 of 17 checks passed
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.

Unable to open Advanced Search Dialog in Bundle Repository view more than once
2 participants