Ghidra is a software reverse engineering (SRE) framework
GP-4798 Corrected transaction error when DT Archive upgrade is performed
ghidra185a94fc56633
diff --git a/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/database/data/DataTypeManagerDB.java b/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/database/data/DataTypeManagerDB.javaindex 2a0671d78d..e5058f0edf 100644--- a/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/database/data/DataTypeManagerDB.java+++ b/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/database/data/DataTypeManagerDB.java@@ -4,9 +4,9 @@* Licensed under the Apache License, Version 2.0 (the "License");* you may not use this file except in compliance with the License.* You may obtain a copy of the License at- *+ ** http://www.apache.org/licenses/LICENSE-2.0- *+ ** Unless required by applicable law or agreed to in writing, software* distributed under the License is distributed on an "AS IS" BASIS,* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.@@ -319,7 +319,7 @@ abstract public class DataTypeManagerDB implements DataTypeManager {private void initPackedDatabase(ResourceFile packedDBfile, OpenMode openMode,TaskMonitor monitor) throws CancelledException, IOException {- long txId = dbHandle.startTransaction();+ Long txId = dbHandle.startTransaction();try {init(openMode, monitor);@@ -337,6 +337,9 @@ abstract public class DataTypeManagerDB implements DataTypeManager {}catch (VersionException e) {if (openMode == OpenMode.UPDATE && e.isUpgradable()) {+ // Try again with UPGRADE mode+ dbHandle.endTransaction(txId, true);+ txId = null;initPackedDatabase(packedDBfile, OpenMode.UPGRADE, monitor);}else {@@ -345,7 +348,9 @@ abstract public class DataTypeManagerDB implements DataTypeManager {}}finally {- dbHandle.endTransaction(txId, true);+ if (txId != null) {+ dbHandle.endTransaction(txId, true);+ }}}diff --git a/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/data/StandAloneDataTypeManager.java b/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/data/StandAloneDataTypeManager.javaindex 8f91a6df36..4fe6f61dae 100644--- a/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/data/StandAloneDataTypeManager.java+++ b/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/data/StandAloneDataTypeManager.java@@ -4,9 +4,9 @@* Licensed under the Apache License, Version 2.0 (the "License");* you may not use this file except in compliance with the License.* You may obtain a copy of the License at- *+ ** http://www.apache.org/licenses/LICENSE-2.0- *+ ** Unless required by applicable law or agreed to in writing, software* distributed under the License is distributed on an "AS IS" BASIS,* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.@@ -836,7 +836,7 @@ public class StandAloneDataTypeManager extends DataTypeManagerDB implements Clos}protected void initTransactionState() {- dbHandle.setMaxUndos(NUM_UNDOS);+ clearUndo();}@Override@@ -953,6 +953,8 @@ public class StandAloneDataTypeManager extends DataTypeManagerDB implements Closprotected synchronized void clearUndo() {undoList.clear();redoList.clear();+ dbHandle.setMaxUndos(0);+ dbHandle.setMaxUndos(NUM_UNDOS);}/**@@ -1037,7 +1039,12 @@ public class StandAloneDataTypeManager extends DataTypeManagerDB implements Clos@Overridepublic synchronized void close() {- clearUndo();+ if (dbHandle.isTransactionActive()) {+ Msg.error(this, "DTM closed with active transaction",+ new RuntimeException("DTM closed with active transaction"));+ }+ undoList.clear();+ redoList.clear();if (!dbHandle.isClosed()) {dbHandle.close();}