GP-667 fix XmlImport bookmark overwrite existing

This commit is contained in:
dev747368 2021-02-05 13:22:26 -05:00 committed by ghidra1
parent 01b6027c77
commit 3d36d914be

View File

@ -1,6 +1,5 @@
/* ###
* IP: GHIDRA
* REVIEWED: YES
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -16,9 +15,18 @@
*/
package ghidra.app.util.xml;
import org.xml.sax.SAXParseException;
import ghidra.app.util.importer.MessageLog;
import ghidra.program.model.address.*;
import ghidra.program.model.listing.*;
import ghidra.program.model.address.Address;
import ghidra.program.model.address.AddressFactory;
import ghidra.program.model.address.AddressFormatException;
import ghidra.program.model.address.AddressIterator;
import ghidra.program.model.address.AddressSetView;
import ghidra.program.model.listing.Bookmark;
import ghidra.program.model.listing.BookmarkManager;
import ghidra.program.model.listing.BookmarkType;
import ghidra.program.model.listing.Program;
import ghidra.util.XmlProgramUtilities;
import ghidra.util.exception.CancelledException;
import ghidra.util.task.TaskMonitor;
@ -27,8 +35,6 @@ import ghidra.util.xml.XmlWriter;
import ghidra.xml.XmlElement;
import ghidra.xml.XmlPullParser;
import org.xml.sax.SAXParseException;
class BookmarksXmlMgr {
private BookmarkManager bookmarkMgr;
private AddressFactory factory;
@ -97,13 +103,13 @@ class BookmarksXmlMgr {
}
try {
if (!overwrite) {
if (bookmarkMgr.getBookmark(addr, type, category) != null) {
log.appendMsg("Conflicting '" + type + "' BOOKMARK ignored at: " + addr);
return;
}
boolean hasExistingBookmark = bookmarkMgr.getBookmark(addr, type, category) != null;
if (overwrite || !hasExistingBookmark) {
bookmarkMgr.setBookmark(addr, type, category, comment);
}
if (!overwrite && hasExistingBookmark) {
log.appendMsg("Conflicting '" + type + "' BOOKMARK ignored at: " + addr);
}
bookmarkMgr.setBookmark(addr, type, category, comment);
}
catch (Exception e) {
log.appendException(e);