Skip to content

Commit

Permalink
Fix: Unable to open Advanced Search Dialog more than once
Browse files Browse the repository at this point in the history
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
  • Loading branch information
ptziegler authored and HannesWell committed Aug 6, 2024
1 parent 8f742cd commit 90a3dc1
Showing 1 changed file with 0 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@

import java.beans.PropertyChangeListener;
import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;

Expand Down Expand Up @@ -70,8 +68,6 @@ protected Control createDialogArea(Composite parent) {

PropertyChangeListener changeListener = evt -> updateFromPanel();

final List<Image> images = new LinkedList<>();

for (Entry<String, SearchPanel> panelEntry : panelMap.entrySet()) {
String title = panelEntry.getKey();
SearchPanel panel = panelEntry.getValue();
Expand All @@ -91,20 +87,12 @@ protected Control createDialogArea(Composite parent) {

Image image = panel.createImage(tabFolder.getDisplay());
if (image != null) {
images.add(image);
item.setImage(image);
}

panel.addPropertyChangeListener(changeListener);
}

tabFolder.addDisposeListener(e -> {
for (Image image : images) {
if (!image.isDisposed())
image.dispose();
}
});

tabFolder.setSelection(activeTabIndex);
SearchPanel currentPanel = (SearchPanel) tabFolder.getItem(activeTabIndex)
.getData();
Expand Down

0 comments on commit 90a3dc1

Please sign in to comment.