From 44bcd58051919e62fdbaa8ba823b7bdff575b6c6 Mon Sep 17 00:00:00 2001 From: Max Rossmannek Date: Sat, 21 Nov 2020 14:38:15 +0100 Subject: [PATCH] Fix Undo command The Undo command broke in 48dff11 when the `onModify` hook got added to its execution in order to fix #2213. The reason for it begin broke is that a Task object is created in an unsafe manner because the `prior` task may be empty. Catching this case fixes the bug. --- src/TDB2.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/TDB2.cpp b/src/TDB2.cpp index ee6c38de7..353f3ac4b 100644 --- a/src/TDB2.cpp +++ b/src/TDB2.cpp @@ -839,7 +839,9 @@ void TDB2::revert () // - erase from completed // - if in backlog, erase, else cannot undo - Task old = Task (prior); + Task old = Task (); + if (prior != "") + old = Task (prior); Context::getContext ().hooks.onModify (Task (current), old); // Modify other data files accordingly.