Skip to content

Commit

Permalink
Strange SWT dispose problem. This seems not to be introduced by the r…
Browse files Browse the repository at this point in the history
…ecent change but might be an interaction with Eclipse. I noticed this in the last version also. It looks like a helper object is used to detect that anSWT object is not disposed properly. It looks like the Icons class was not properly using the caching map for one method. Now properly cached.

---
 Signed-off-by: Peter Kriens <Peter.Kriens@aQute.biz>

Signed-off-by: Peter Kriens <Peter.Kriens@aQute.biz>
  • Loading branch information
pkriens committed Jun 1, 2023
1 parent dffd307 commit 0d1e8fe
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public void update(ViewerCell cell) {
cell.setStyleRanges(label.getStyleRanges());

// Get the icon from the capability namespace
Image icon = Icons.image(R5LabelFormatter.getNamespaceImagePath(cap.getNamespace()), false);
Image icon = Icons.image(R5LabelFormatter.getNamespaceImagePath(cap.getNamespace()));
cell.setImage(icon);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,8 @@ public void update(ViewerCell cell) {
if (element instanceof RequirementWrapper) {
RequirementWrapper rw = (RequirementWrapper) element;

Image icon = Icons.image(R5LabelFormatter.getNamespaceImagePath(rw.requirement.getNamespace()), true);
if (icon != null)
cell.setImage(icon);
Image icon = Icons.image(R5LabelFormatter.getNamespaceImagePath(rw.requirement.getNamespace()));
cell.setImage(icon);

StyledString label = getLabel(rw.requirement);
if (rw.resolved)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public void update(ViewerCell cell) {

// Get the icon from the capability namespace
icon = Icons.image(R5LabelFormatter.getNamespaceImagePath(item.getCapability()
.getNamespace()), true);
.getNamespace()));
} else if (element instanceof Requirement) {
Requirement requirement = (Requirement) element;
if (Namespace.RESOLUTION_OPTIONAL.equals(requirement.getDirectives()
Expand Down
7 changes: 5 additions & 2 deletions bndtools.core/src/org/bndtools/core/ui/icons/Icons.java
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,11 @@ public static Image image(String name, boolean nullIfAbsent) {

Key k = new Key(name);
synchronized (images) {
Image image = desc.createImage();
images.put(k, image);
Image image = images.get(k);
if (image == null) {
image = desc.createImage();
images.put(k, image);
}
return image;
}
}
Expand Down

0 comments on commit 0d1e8fe

Please sign in to comment.