mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-05 02:39:44 +02:00
Merge remote-tracking branch 'origin/GP-4165_ghidra1_ProgramUpgradeCacheImprovement--SQUASHED'
This commit is contained in:
commit
4b465a980e
2 changed files with 19 additions and 7 deletions
|
@ -304,11 +304,9 @@ public class ProgramManagerPlugin extends Plugin implements ProgramManager, Opti
|
|||
program = programMgr.getOpenProgram(locator);
|
||||
if (program != null) {
|
||||
program.addConsumer(consumer);
|
||||
if (!program.isChanged()) {
|
||||
// Don't put modified programs into the cache.
|
||||
// NOTE: This will prevent upgraded programs from being added to the cache
|
||||
// which are already open in the tool. This could be improved if we could
|
||||
// distinguish between upgrade and non-upgrade changes.
|
||||
if (!program.isChanged() || ProgramUtilities.isChangedWithUpgradeOnly(program)) {
|
||||
// Don't put modified programs into the cache unless the only change
|
||||
// corresponds to an upgrade during its instantiation.
|
||||
programCache.put(locator, program);
|
||||
}
|
||||
return program;
|
||||
|
|
|
@ -15,6 +15,8 @@
|
|||
*/
|
||||
package ghidra.program.util;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import ghidra.program.model.address.Address;
|
||||
import ghidra.program.model.listing.*;
|
||||
import ghidra.program.model.mem.MemoryAccessException;
|
||||
|
@ -23,8 +25,6 @@ import ghidra.util.*;
|
|||
import ghidra.util.exception.DuplicateNameException;
|
||||
import ghidra.util.exception.InvalidInputException;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* General utility class that provides convenience methods
|
||||
* to deal with Program objects.
|
||||
|
@ -173,4 +173,18 @@ public class ProgramUtilities {
|
|||
Msg.error(ProgramUtilities.class, "Unexpected Exception", e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if a program has a single unsaved change which corresponds to an
|
||||
* upgrade which occured during instantiation.
|
||||
* @param program the program to be checked for an unsaved upgrade condition.
|
||||
* @return true if program upgraded and has not been saved, else false
|
||||
*/
|
||||
public static boolean isChangedWithUpgradeOnly(Program program) {
|
||||
// The only non-undoable change is an upgrade that occurs during instantiation
|
||||
if (!program.isChanged()) {
|
||||
return false;
|
||||
}
|
||||
return !program.canUndo();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue