Skip to content

Commit b0e1b3e

Browse files
committed
Skip the method PluginsTab::performApply until after activation
If this method (or part of it) is run before the tab has been activated then the default configuration passed as parameter will be modified and incorrect values will be introduced. This commit fixes a regression introduced in 98a5865 Fixes #1250
1 parent 8046286 commit b0e1b3e

File tree

2 files changed

+20
-11
lines changed

2 files changed

+20
-11
lines changed
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
Comparator Errors in 4.32 I-Build I20240304-0140
2-
Update to IPDELauncherConstants
3-
https://github.com/eclipse-pde/eclipse.pde/issues/1250
2+
Update to IPDELauncherConstants

ui/org.eclipse.pde.ui/src/org/eclipse/pde/ui/launcher/PluginsTab.java

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ public class PluginsTab extends AbstractLauncherTab {
5959
private Combo fDefaultAutoStart;
6060
private Spinner fDefaultStartLevel;
6161
private final Listener fListener;
62+
private boolean fActivated;
6263

6364
private static final int DEFAULT_SELECTION = 0;
6465
private static final int PLUGIN_SELECTION = 1;
@@ -156,6 +157,16 @@ public void createControl(Composite parent) {
156157

157158
@Override
158159
public void initializeFrom(ILaunchConfiguration configuration) {
160+
// Long-running initialization happens on first activation of this tab
161+
}
162+
163+
@Override
164+
public void activated(ILaunchConfigurationWorkingCopy configuration) {
165+
if (fActivated) {
166+
// Since this method can be expensive, only activate this tab once.
167+
return;
168+
}
169+
159170
try {
160171
int index = DEFAULT_SELECTION;
161172
if (configuration.getAttribute(IPDELauncherConstants.USE_CUSTOM_FEATURES, false)) {
@@ -171,6 +182,9 @@ public void initializeFrom(ILaunchConfiguration configuration) {
171182
fDefaultAutoStart.setText(Boolean.toString(auto));
172183
int level = configuration.getAttribute(IPDELauncherConstants.DEFAULT_START_LEVEL, 4);
173184
fDefaultStartLevel.setSelection(level);
185+
186+
// If everything ran smoothly, this tab is activated
187+
fActivated = true;
174188
} catch (CoreException e) {
175189
PDEPlugin.log(e);
176190
}
@@ -185,10 +199,13 @@ public void setDefaults(ILaunchConfigurationWorkingCopy configuration) {
185199

186200
@Override
187201
public void performApply(ILaunchConfigurationWorkingCopy configuration) {
202+
if (!fActivated) {
203+
return;
204+
}
188205
int index = fSelectionCombo.getSelectionIndex();
189206
configuration.setAttribute(IPDELauncherConstants.USE_DEFAULT, index == DEFAULT_SELECTION);
190207
configuration.setAttribute(IPDELauncherConstants.USE_CUSTOM_FEATURES, index == FEATURE_SELECTION);
191-
fBlock.performApply(configuration);
208+
fBlock.performApply(configuration);
192209
// clear default values for auto-start and start-level if default
193210
String autoText = fDefaultAutoStart.getText();
194211
if (Boolean.toString(false).equals(autoText)) {
@@ -217,16 +234,9 @@ public Image getImage() {
217234
return fImage;
218235
}
219236

220-
/**
221-
* Validates the tab. If the feature option is chosen, and the workspace is not correctly set up,
222-
* the error message is set.
223-
*
224-
* @see org.eclipse.pde.ui.launcher.AbstractLauncherTab#validateTab()
225-
*/
226237
@Override
227238
public void validateTab() {
228-
String errorMessage = null;
229-
setErrorMessage(errorMessage);
239+
setErrorMessage(null);
230240
}
231241

232242
@Override

0 commit comments

Comments
 (0)