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 SWT Resource not properly disposed on LSPSymbolInWorkspaceDialog #801

Merged
merged 1 commit into from
Sep 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,10 @@ public boolean isConsistentItem(Object item) {

private final IProject project;

public LSPSymbolInWorkspaceDialog(Shell shell, IProject project) {
public LSPSymbolInWorkspaceDialog(Shell shell, IProject project, BoldStylerProvider stylerProvider) {
super(shell);
this.project = project;
this.labelProvider = new InternalSymbolsLabelProvider(new BoldStylerProvider(shell.getFont()));
this.labelProvider = new InternalSymbolsLabelProvider(stylerProvider);
setMessage(Messages.LSPSymbolInWorkspaceDialog_DialogLabel);
setTitle(Messages.LSPSymbolInWorkspaceDialog_DialogTitle);
setListLabelProvider(labelProvider);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.text.contentassist.BoldStylerProvider;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.lsp4e.LSPEclipseUtils;
import org.eclipse.lsp4e.LanguageServers;
Expand Down Expand Up @@ -56,10 +57,13 @@ public Object execute(ExecutionEvent event) throws ExecutionException {
if (site == null) {
return null;
}
final var dialog = new LSPSymbolInWorkspaceDialog(site.getShell(), project);
var styleProvider = new BoldStylerProvider(site.getShell().getFont());
final var dialog = new LSPSymbolInWorkspaceDialog(site.getShell(), project, styleProvider);
if (dialog.open() != IDialogConstants.OK_ID) {
Copy link
Contributor

Choose a reason for hiding this comment

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

what about

int code = dialog.open();
styleProvider.dispose();
if (code != IDialogConstants.OK_ID) {
	return null;
}

then we do not need to repeat the dispose call in both branches

Copy link
Contributor Author

Choose a reason for hiding this comment

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

See PR #803

styleProvider.dispose();
return null;
}
styleProvider.dispose();
final var symbolInformation = ((WorkspaceSymbol) dialog.getFirstResult()).getLocation();
if (symbolInformation.isLeft()) {
LSPEclipseUtils.openInEditor(symbolInformation.getLeft());
Expand Down