GP-3998 DT Archive uses retained data organization when associated

language error occurs.
This commit is contained in:
ghidra1 2023-11-02 11:31:35 -04:00
parent 6193c2f046
commit 171d13bae8
2 changed files with 31 additions and 6 deletions

View file

@ -315,7 +315,7 @@ abstract public class DataTypeManagerDB implements DataTypeManager {
try (Transaction tx = openTransaction("")) { try (Transaction tx = openTransaction("")) {
init(openMode, monitor); init(openMode, monitor);
if (openMode != DBConstants.CREATE && hasDataOrganizationChange()) { if (openMode != DBConstants.CREATE && hasDataOrganizationChange(true)) {
// check for data organization change with possible upgrade // check for data organization change with possible upgrade
handleDataOrganizationChange(openMode, monitor); handleDataOrganizationChange(openMode, monitor);
} }
@ -341,7 +341,7 @@ abstract public class DataTypeManagerDB implements DataTypeManager {
/** /**
* Constructor for a database-backed <code>DataTypeManagerDB</code> extension. * Constructor for a database-backed <code>DataTypeManagerDB</code> extension.
* NOTE: This does not check for and handle data organization changes which must be * NOTE: This does not check for and handle data organization changes which must be
* handled later (use {@link #hasDataOrganizationChange()} and * handled later (use {@link #hasDataOrganizationChange(boolean)} and
* {@link #compilerSpecChanged(TaskMonitor)} to check for and initiate response to changes). * {@link #compilerSpecChanged(TaskMonitor)} to check for and initiate response to changes).
* *
* @param handle database handle * @param handle database handle
@ -842,7 +842,7 @@ abstract public class DataTypeManagerDB implements DataTypeManager {
throw new ReadOnlyException(); throw new ReadOnlyException();
} }
boolean hasDataOrgChange = hasDataOrganizationChange(); boolean hasDataOrgChange = hasDataOrganizationChange(false);
saveDataOrganization(); saveDataOrganization();
@ -854,8 +854,21 @@ abstract public class DataTypeManagerDB implements DataTypeManager {
// on function definitions // on function definitions
} }
protected final boolean hasDataOrganizationChange() throws IOException { /**
* Check if the active {@link #getDataOrganization()} differs from the stored data organization.
* False will be returned when {@code ifPreviouslyStored} is true and data organization has never
* beeen saved.
* @param ifPreviouslyStored if true and data organization has never been saved false will be returned
* @return true if a data organization change has occured
* @throws IOException if an IO error occurs
*/
protected final boolean hasDataOrganizationChange(boolean ifPreviouslyStored)
throws IOException {
// compare DB-stored data organization with the one in affect // compare DB-stored data organization with the one in affect
DataOrganization storedDataOrg = readDataOrganization();
if (ifPreviouslyStored && storedDataOrg == null) {
return false;
}
return !Objects.equals(readDataOrganization(), getDataOrganization()); return !Objects.equals(readDataOrganization(), getDataOrganization());
} }
@ -3943,9 +3956,21 @@ abstract public class DataTypeManagerDB implements DataTypeManager {
@Override @Override
public final DataOrganization getDataOrganization() { public final DataOrganization getDataOrganization() {
if (dataOrganization == null) {
try {
// Initialization of dataOrganization may never have been established
// if either an architecture has never been specified or a language
// error occured during initializtion. In such cases the stored
// data organization should be used if available.
dataOrganization = readDataOrganization();
}
catch (IOException e) {
dbError(e);
}
if (dataOrganization == null) { if (dataOrganization == null) {
dataOrganization = DataOrganizationImpl.getDefaultOrganization(); dataOrganization = DataOrganizationImpl.getDefaultOrganization();
} }
}
return dataOrganization; return dataOrganization;
} }

View file

@ -201,7 +201,7 @@ public class StandAloneDataTypeManager extends DataTypeManagerDB implements Clos
Lock lock, TaskMonitor monitor) Lock lock, TaskMonitor monitor)
throws CancelledException, VersionException, IOException { throws CancelledException, VersionException, IOException {
super(handle, null, openMode, null, errHandler, lock, monitor); super(handle, null, openMode, null, errHandler, lock, monitor);
if (openMode != DBConstants.CREATE && hasDataOrganizationChange()) { if (openMode != DBConstants.CREATE && hasDataOrganizationChange(true)) {
handleDataOrganizationChange(openMode, monitor); handleDataOrganizationChange(openMode, monitor);
} }
} }