mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2026-06-01 14:54:29 +08:00
Merge remote-tracking branch 'origin/GP-1-dragonmacher-review-tool-close-bug'
This commit is contained in:
+40
-39
@@ -277,45 +277,46 @@ public abstract class StandAloneApplication implements GenericStandAloneApplicat
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ToolServices getToolServices() {
|
public ToolServices getToolServices() {
|
||||||
return new ToolServicesAdapter() {
|
return new StandAloneToolServices();
|
||||||
|
|
||||||
@Override
|
|
||||||
public void closeTool(PluginTool t) {
|
|
||||||
System.exit(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void saveTool(PluginTool saveTool) {
|
|
||||||
Element toolElement = saveTool.saveToXml(true);
|
|
||||||
Element dataStateElement = saveTool.saveDataStateToXml(false);
|
|
||||||
Element rootElement = new Element("Root");
|
|
||||||
rootElement.addContent(toolElement);
|
|
||||||
rootElement.addContent(dataStateElement);
|
|
||||||
File savedToolFile =
|
|
||||||
new File(Application.getUserSettingsDirectory(), SAVED_TOOL_FILE);
|
|
||||||
OutputStream os = null;
|
|
||||||
try {
|
|
||||||
os = new FileOutputStream(savedToolFile);
|
|
||||||
Document doc = new Document(rootElement);
|
|
||||||
XMLOutputter xmlout = new GenericXMLOutputter();
|
|
||||||
xmlout.output(doc, os);
|
|
||||||
os.close();
|
|
||||||
}
|
|
||||||
catch (Exception e) {
|
|
||||||
Msg.error(this, "Error saving tool", e);
|
|
||||||
try {
|
|
||||||
if (os != null) {
|
|
||||||
os.close();
|
|
||||||
}
|
|
||||||
savedToolFile.delete();
|
|
||||||
}
|
|
||||||
catch (Exception exc) {
|
|
||||||
// cleanup, don't care
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected static class StandAloneToolServices extends ToolServicesAdapter {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void closeTool(PluginTool t) {
|
||||||
|
System.exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void saveTool(PluginTool saveTool) {
|
||||||
|
Element toolElement = saveTool.saveToXml(true);
|
||||||
|
Element dataStateElement = saveTool.saveDataStateToXml(false);
|
||||||
|
Element rootElement = new Element("Root");
|
||||||
|
rootElement.addContent(toolElement);
|
||||||
|
rootElement.addContent(dataStateElement);
|
||||||
|
File savedToolFile =
|
||||||
|
new File(Application.getUserSettingsDirectory(), SAVED_TOOL_FILE);
|
||||||
|
OutputStream os = null;
|
||||||
|
try {
|
||||||
|
os = new FileOutputStream(savedToolFile);
|
||||||
|
Document doc = new Document(rootElement);
|
||||||
|
XMLOutputter xmlout = new GenericXMLOutputter();
|
||||||
|
xmlout.output(doc, os);
|
||||||
|
os.close();
|
||||||
|
}
|
||||||
|
catch (Exception e) {
|
||||||
|
Msg.error(this, "Error saving tool", e);
|
||||||
|
try {
|
||||||
|
if (os != null) {
|
||||||
|
os.close();
|
||||||
|
}
|
||||||
|
savedToolFile.delete();
|
||||||
|
}
|
||||||
|
catch (Exception exc) {
|
||||||
|
// cleanup, don't care
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user