Merge remote-tracking branch

'origin/GP-7096-dragonmacher-headless-last-project--SQUASHED' into patch
(Closes #9414)
This commit is contained in:
Ryan Kurtz
2026-07-28 04:57:34 -04:00
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 { 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

@@ -4,9 +4,9 @@
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -23,20 +23,20 @@ import ghidra.framework.options.Options;
*/ */
public enum DefaultLaunchMode { public enum DefaultLaunchMode {
REUSE_TOOL("Reuse acceptable running tool"), REUSE_TOOL("Reuse Tool"),
NEW_TOOL("Launch new default tool"); NEW_TOOL("New Tool");
public static DefaultLaunchMode DEFAULT = NEW_TOOL; public static DefaultLaunchMode DEFAULT = NEW_TOOL;
private String str; private String description;
private DefaultLaunchMode(String str) { private DefaultLaunchMode(String str) {
this.str = str; this.description = str;
} }
@Override @Override
public String toString() { 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. * Update preferences file with list of known projects.
*/ */
void updatePreferences() { protected void updatePreferences() {
setProjectLocatorProperty(recentlyOpenedProjectsList, RECENT_PROJECTS); setProjectLocatorProperty(recentlyOpenedProjectsList, RECENT_PROJECTS);
setProjectURLProperty(recentlyViewedProjectsList, VIEWED_PROJECTS); setProjectURLProperty(recentlyViewedProjectsList, VIEWED_PROJECTS);