GP-7096 - Prevent headless analyzer from updating last opened project

This commit is contained in:
dragonmacher
2026-07-27 14:40:39 -04:00
parent b855a9164f
commit a16770a969
3 changed files with 29 additions and 9 deletions

View File

@@ -1859,7 +1859,27 @@ public class HeadlessAnalyzer {
}
}
/**
* A headless version of the {@link DefaultProjectManager} that does not update the project's
* preferences. This prevents the headless environment from overwriting settings GUI
* installations.
*/
private static class HeadlessGhidraProjectManager extends DefaultProjectManager {
// this exists just to allow access to the constructor
@Override
public void setLastOpenedProject(ProjectLocator projectLocator) {
// No need to save this for headless. We also do not want to affect the GUI by saving
// this value.
}
@Override
public ProjectLocator getLastOpenedProject() {
return null;
}
@Override
protected void updatePreferences() {
// nothing to save
}
}
}

View File

@@ -23,20 +23,20 @@ import ghidra.framework.options.Options;
*/
public enum DefaultLaunchMode {
REUSE_TOOL("Reuse acceptable running tool"),
NEW_TOOL("Launch new default tool");
REUSE_TOOL("Reuse Tool"),
NEW_TOOL("New Tool");
public static DefaultLaunchMode DEFAULT = NEW_TOOL;
private String str;
private String description;
private DefaultLaunchMode(String str) {
this.str = str;
this.description = str;
}
@Override
public String toString() {
return str;
return description;
}
}

View File

@@ -568,7 +568,7 @@ public class DefaultProjectManager implements ProjectManager {
/**
* Update preferences file with list of known projects.
*/
void updatePreferences() {
protected void updatePreferences() {
setProjectLocatorProperty(recentlyOpenedProjectsList, RECENT_PROJECTS);
setProjectURLProperty(recentlyViewedProjectsList, VIEWED_PROJECTS);