Ghidra is a software reverse engineering (SRE) framework
GP-2695 - Added an option to have the application not open the previous project
dragonmacher68b39cace29d
diff --git a/Ghidra/Features/Base/src/main/help/help/topics/Tool/ToolOptions_Dialog.htm b/Ghidra/Features/Base/src/main/help/help/topics/Tool/ToolOptions_Dialog.htmindex e854b49918..1b28628dec 100644--- a/Ghidra/Features/Base/src/main/help/help/topics/Tool/ToolOptions_Dialog.htm+++ b/Ghidra/Features/Base/src/main/help/help/topics/Tool/ToolOptions_Dialog.htm@@ -385,7 +385,7 @@</OL></BLOCKQUOTE>- <H3><B>Tool</B></H3>+ <H3><A name="Front_End_Tool_Options"></A><B>Tool</B></H3><BLOCKQUOTE><P>Some <B>Tool</B> options can only be set from the <A href=@@ -418,6 +418,24 @@others.</TD></TR>++ <TR>+ <TD valign="top" width="200" align="left">Automatically Save Tools</TD>++ <TD valign="top" align="left">This controls whether Ghidra will save tool state+ when the tool is closed.</TD>+ </TR>+++ <TR>+ <TD valign="top" width="200" align="left">Restore Previous Project</TD>++ <TD valign="top" align="left">This controls+ whether or not Ghidra automatically opens the previously loaded project on+ startup.</TD>+ </TR>++<TR><TD valign="top" width="200" align="left"><A name="Use_Inverted_Colors"></A>UseInverted Colors</TD>diff --git a/Ghidra/Features/Base/src/main/java/ghidra/GhidraRun.java b/Ghidra/Features/Base/src/main/java/ghidra/GhidraRun.javaindex f9a52b603e..b7e5951772 100644--- a/Ghidra/Features/Base/src/main/java/ghidra/GhidraRun.java+++ b/Ghidra/Features/Base/src/main/java/ghidra/GhidraRun.java@@ -53,14 +53,14 @@ import ghidra.util.task.TaskMonitorAdapter;* from when the last time Ghidra was run, (3) a class in the file was* not found, or (4) a modification date specified in the classes file for* a jar file is older than the actual jar file's modification date.- *+ ** <p><strong>Note</strong>: The Plugin path is a user preference that* indicates locations for where classes for plugins and data types should* be searched; the Plugin path can include jar files just like a classpath.* The Plugin path can be changed by using the <i>Edit Plugin Path</i> dialog,* displayed from the <i>Edit->Edit Plugin Path...</i> menu option on the main* Ghidra project window.- *+ ** @see ghidra.GhidraLauncher*/public class GhidraRun implements GhidraLaunchable {@@ -169,7 +169,8 @@ public class GhidraRun implements GhidraLaunchable {reopen = false;}}- if (projectLocator == null) {++ if (projectLocator == null && tool.shouldRestorePreviousProject()) {updateSplashScreenStatusMessage("Checking for last opened project...");projectLocator = pm.getLastOpenedProject();}diff --git a/Ghidra/Framework/Project/src/main/java/ghidra/framework/main/FrontEndTool.java b/Ghidra/Framework/Project/src/main/java/ghidra/framework/main/FrontEndTool.javaindex 2afa2f2b59..57d5b4b181 100644--- a/Ghidra/Framework/Project/src/main/java/ghidra/framework/main/FrontEndTool.java+++ b/Ghidra/Framework/Project/src/main/java/ghidra/framework/main/FrontEndTool.java@@ -94,7 +94,11 @@ public class FrontEndTool extends PluginTool implements OptionsChangeListener {private static final String ENABLE_COMPRESSED_DATABUFFER_OUTPUT ="Use DataBuffer Output Compression";+ private static final String RESTORE_PREVIOUS_PROJECT_NAME = "Restore Previous Project";+ private boolean shouldRestorePreviousProject;+private static final int MIN_HEIGHT = 600;+/*** Preference name for whether to show the "What's New" help page when the* Ghidra Project Window is displayed.@@ -153,6 +157,8 @@ public class FrontEndTool extends PluginTool implements OptionsChangeListener {AppInfo.setFrontEndTool(this);AppInfo.setActiveProject(getProject());++ initFrontEndOptions();}private void ensureSize() {@@ -291,15 +297,20 @@ public class FrontEndTool extends PluginTool implements OptionsChangeListener {private void initFrontEndOptions() {ToolOptions options = getOptions(ToolConstants.TOOL_OPTIONS);- HelpLocation help = new HelpLocation(ToolConstants.TOOL_HELP_TOPIC, "Save_Tool");+ HelpLocation help =+ new HelpLocation(ToolConstants.TOOL_HELP_TOPIC, "Front_End_Tool_Options");options.registerOption(AUTOMATICALLY_SAVE_TOOLS, true, help,- "When enabled tools will be saved " + "when they are closed");+ "When enabled tools will be saved when they are closed");options.registerOption(USE_ALERT_ANIMATION_OPTION_NAME, true, help,- "Signals that user notifications " +- "should be animated. This makes notifications more distinguishable.");+ "Signals that user notifications should be animated. This makes notifications more " ++ "distinguishable.");options.registerOption(ENABLE_COMPRESSED_DATABUFFER_OUTPUT, Boolean.FALSE, help,- "When enabled data buffers sent to Ghidra Server are compressed (see server configuration for other direction)");+ "When enabled data buffers sent to Ghidra Server are compressed (see server " ++ "configuration for other direction)");++ options.registerOption(RESTORE_PREVIOUS_PROJECT_NAME, Boolean.TRUE, help,+ "Restore the previous project when Ghidra starts.");boolean autoSave = options.getBoolean(AUTOMATICALLY_SAVE_TOOLS, true);GhidraTool.autoSave = autoSave;@@ -311,6 +322,8 @@ public class FrontEndTool extends PluginTool implements OptionsChangeListener {options.getBoolean(ENABLE_COMPRESSED_DATABUFFER_OUTPUT, false);DataBuffer.enableCompressedSerializationOutput(compressDataBuffers);+ shouldRestorePreviousProject = options.getBoolean(RESTORE_PREVIOUS_PROJECT_NAME, true);+options.addOptionsChangeListener(this);}@@ -326,6 +339,9 @@ public class FrontEndTool extends PluginTool implements OptionsChangeListener {else if (ENABLE_COMPRESSED_DATABUFFER_OUTPUT.equals(optionName)) {DataBuffer.enableCompressedSerializationOutput((Boolean) newValue);}+ else if (RESTORE_PREVIOUS_PROJECT_NAME.equals(optionName)) {+ shouldRestorePreviousProject = (Boolean) newValue;+ }}@Override@@ -350,14 +366,19 @@ public class FrontEndTool extends PluginTool implements OptionsChangeListener {return;}- ToolOptions options = getOptions(ToolConstants.TOOL_OPTIONS);- options.removeOptionsChangeListener(this);-configureToolAction.setEnabled(true);setProject(project);AppInfo.setActiveProject(project);plugin.setActiveProject(project);- initFrontEndOptions();+ }++ /**+ * Checks to see if the previous project should be restored+ *+ * @return true if the previous project should be restored; otherwise, false+ */+ public boolean shouldRestorePreviousProject() {+ return shouldRestorePreviousProject;}/**