Skip to content

Commit faf37b6

Browse files
fix: color resource leak (#239)
1 parent 3037c1b commit faf37b6

1 file changed

Lines changed: 39 additions & 29 deletions

File tree

plugin/src/main/java/io/snyk/eclipse/plugin/wizards/SnykWizardAuthenticatePage.java

Lines changed: 39 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,22 @@
1717
import io.snyk.eclipse.plugin.properties.preferences.Preferences;
1818

1919
public class SnykWizardAuthenticatePage extends WizardPage implements Listener {
20-
private Text endpoint;
21-
private Button unknownCerts;
22-
private String trustMessage = "⚠️ When scanning folder files, Snyk may automatically execute code such as invoking the package manager to get dependency information. "
23-
+ "You should only scan projects you trust. <a href=\"https://docs.snyk.io/ide-tools/eclipse-plugin/folder-trust\">More Info</a>"
24-
+ "\n\nOn finishing the wizard, the plugin will open a browser to authenticate you, trust the current workspace projects and trigger a scan.";
25-
26-
public SnykWizardAuthenticatePage() {
27-
super("Snyk Wizard");
28-
setTitle("Authenticate");
29-
setDescription("Review the endpoint configuration, clicking 'Finish' will authenticate with Snyk; this will open a new browser window.");
30-
}
31-
32-
@Override
33-
public void createControl(Composite parent) {
20+
private Text endpoint;
21+
private Button unknownCerts;
22+
private String trustMessage = "⚠️ When scanning folder files, Snyk may automatically execute code such as invoking the package manager to get dependency information. "
23+
+ "You should only scan projects you trust. <a href=\"https://docs.snyk.io/ide-tools/eclipse-plugin/folder-trust\">More Info</a>"
24+
+ "\n\nOn finishing the wizard, the plugin will open a browser to authenticate you, trust the current workspace projects and trigger a scan.";
25+
private Color blackColor;
26+
27+
public SnykWizardAuthenticatePage() {
28+
super("Snyk Wizard");
29+
setTitle("Authenticate");
30+
setDescription(
31+
"Review the endpoint configuration, clicking 'Finish' will authenticate with Snyk; this will open a new browser window.");
32+
}
33+
34+
@Override
35+
public void createControl(Composite parent) {
3436
Composite composite = new Composite(parent, SWT.NONE);
3537
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
3638

@@ -58,24 +60,32 @@ public void createControl(Composite parent) {
5860
trustText.setText(trustMessage);
5961
gd = new GridData(GridData.FILL_BOTH);
6062
trustText.setLayoutData(gd);
61-
trustText.setBackground(new Color(0, 0, 0, 0));
63+
this.blackColor = new Color(0, 0, 0, 0);
64+
trustText.setBackground(blackColor);
6265
trustText.addListener(SWT.Selection, event -> org.eclipse.swt.program.Program.launch(event.text));
6366

6467
// required to avoid an error in the system
6568
setControl(composite);
6669
setPageComplete(false);
67-
}
68-
69-
public void handleEvent(Event e) {
70-
getWizard().getContainer().updateButtons();
71-
}
72-
73-
public boolean isPageComplete() {
74-
return true;
75-
}
76-
77-
void onEnterPage() {
78-
endpoint.setText(Preferences.getInstance().getEndpoint());
79-
unknownCerts.setSelection(Preferences.getInstance().getBooleanPref(Preferences.INSECURE_KEY));
80-
}
70+
}
71+
72+
@Override
73+
public void dispose() {
74+
this.blackColor.dispose();
75+
this.blackColor = null;
76+
super.dispose();
77+
}
78+
79+
public void handleEvent(Event e) {
80+
getWizard().getContainer().updateButtons();
81+
}
82+
83+
public boolean isPageComplete() {
84+
return true;
85+
}
86+
87+
void onEnterPage() {
88+
endpoint.setText(Preferences.getInstance().getEndpoint());
89+
unknownCerts.setSelection(Preferences.getInstance().getBooleanPref(Preferences.INSECURE_KEY));
90+
}
8191
}

0 commit comments

Comments
 (0)