diff options
Diffstat (limited to 'filemetadata.cpp')
| -rw-r--r-- | filemetadata.cpp | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/filemetadata.cpp b/filemetadata.cpp index 4f75129e..318da70d 100644 --- a/filemetadata.cpp +++ b/filemetadata.cpp @@ -270,9 +270,33 @@ bool FileMetadata::CreateSnapshotedView(BinaryView* data, const std::string& vie } -std::string FileMetadata::BeginUndoActions() +bool FileMetadata::RunUndoableTransaction(std::function<bool()> func) { - char* id = BNBeginUndoActions(m_object); + auto undo = BeginUndoActions(false); + try + { + bool result = func(); + if (result) + { + CommitUndoActions(undo); + } + else + { + RevertUndoActions(undo); + } + return result; + } + catch (...) + { + RevertUndoActions(undo); + throw; + } +} + + +std::string FileMetadata::BeginUndoActions(bool anonymousAllowed) +{ + char* id = BNBeginUndoActions(m_object, anonymousAllowed); std::string result = id; BNFreeString(id); return result; |
