mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-23 14:42:11 +02:00
Fix NPE on initializing the external executables state service provider
- part 2
This commit is contained in:
parent
6b26ac987b
commit
23e5ed3b10
2 changed files with 7 additions and 12 deletions
|
@ -10,8 +10,10 @@
|
||||||
package org.eclipse.tm.terminal.view.ui.internal;
|
package org.eclipse.tm.terminal.view.ui.internal;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.eclipse.tm.terminal.view.ui.local.showin.ExternalExecutablesManager;
|
||||||
import org.eclipse.ui.AbstractSourceProvider;
|
import org.eclipse.ui.AbstractSourceProvider;
|
||||||
import org.eclipse.ui.ISources;
|
import org.eclipse.ui.ISources;
|
||||||
|
|
||||||
|
@ -20,13 +22,11 @@ import org.eclipse.ui.ISources;
|
||||||
*/
|
*/
|
||||||
public class ExternalExecutablesState extends AbstractSourceProvider {
|
public class ExternalExecutablesState extends AbstractSourceProvider {
|
||||||
public final static String CONFIGURED_STATE = "org.eclipse.tm.terminal.external.executable.configured"; //$NON-NLS-1$
|
public final static String CONFIGURED_STATE = "org.eclipse.tm.terminal.external.executable.configured"; //$NON-NLS-1$
|
||||||
private boolean enabled = false;
|
private boolean enabled;
|
||||||
|
|
||||||
public ExternalExecutablesState() {
|
public ExternalExecutablesState() {
|
||||||
// Cannot initialize the state here by calling ExternalExecutablesManager.load(),
|
List<Map<String, String>> externals = ExternalExecutablesManager.load();
|
||||||
// because it will trigger a ExternalExectuablesManger.save() which tries to call
|
this.enabled = (externals != null && !externals.isEmpty());
|
||||||
// the enable() or disable() method here. Better initialize the state from the
|
|
||||||
// load method itself.
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -166,11 +166,6 @@ public class ExternalExecutablesManager {
|
||||||
gitBashSearchDone = true;
|
gitBashSearchDone = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make sure the source provider is initialized properly
|
|
||||||
ISourceProviderService sourceProviderService = (ISourceProviderService) PlatformUI.getWorkbench().getService(ISourceProviderService.class);
|
|
||||||
ExternalExecutablesState stateService = (ExternalExecutablesState) sourceProviderService.getSourceProvider(ExternalExecutablesState.CONFIGURED_STATE);
|
|
||||||
if (l.isEmpty()) stateService.disable(); else stateService.enable();
|
|
||||||
|
|
||||||
return l;
|
return l;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -212,7 +207,7 @@ public class ExternalExecutablesManager {
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
boolean s = f.delete();
|
boolean s = f.delete();
|
||||||
|
|
||||||
stateService.disable();
|
if (stateService != null) stateService.disable();
|
||||||
} else {
|
} else {
|
||||||
FileWriter w = null;
|
FileWriter w = null;
|
||||||
|
|
||||||
|
@ -234,7 +229,7 @@ public class ExternalExecutablesManager {
|
||||||
w = new FileWriter(f);
|
w = new FileWriter(f);
|
||||||
data.store(w, null);
|
data.store(w, null);
|
||||||
|
|
||||||
stateService.enable();
|
if (stateService != null) stateService.enable();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
if (Platform.inDebugMode()) {
|
if (Platform.inDebugMode()) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|
Loading…
Add table
Reference in a new issue