From a6a2fe933e0103464c1a357f987ad10e3bcf6622 Mon Sep 17 00:00:00 2001 From: Neil Date: Wed, 14 Feb 2024 20:51:23 +1100 Subject: Ensure no exceptions when deleting undo history. --- src/UndoHistory.cxx | 7 ++++++- src/UndoHistory.h | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/UndoHistory.cxx b/src/UndoHistory.cxx index 9c1b89c94..1a956b998 100644 --- a/src/UndoHistory.cxx +++ b/src/UndoHistory.cxx @@ -173,6 +173,11 @@ bool UndoActions::AtStart(size_t index) const noexcept { return !types[index-1].mayCoalesce; } +void ScrapStack::Clear() noexcept { + stack.clear(); + current = 0; +} + const char *ScrapStack::Push(const char *text, size_t length) { if (current < stack.length()) { stack.resize(current); @@ -341,7 +346,7 @@ void UndoHistory::DeleteUndoHistory() noexcept { currentAction = 0; savePoint = 0; tentativePoint = -1; - scraps = std::make_unique(); + scraps->Clear(); memory = {}; } diff --git a/src/UndoHistory.h b/src/UndoHistory.h index ab8c24250..1186a1e0e 100644 --- a/src/UndoHistory.h +++ b/src/UndoHistory.h @@ -59,6 +59,7 @@ class ScrapStack { std::string stack; size_t current = 0; public: + void Clear() noexcept; const char *Push(const char *text, size_t length); void SetCurrent(size_t position) noexcept; void MoveForward(size_t length) noexcept; -- cgit v1.2.3