From bfef192aade2335eabe599c2bb164225e857aa59 Mon Sep 17 00:00:00 2001 From: profezzorn Date: Sun, 7 Jun 2020 23:14:08 -0700 Subject: [PATCH] make sure SD is unlocked even if we fail to save --- common/current_preset.h | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/common/current_preset.h b/common/current_preset.h index 542ddddf4..d6c824910 100644 --- a/common/current_preset.h +++ b/common/current_preset.h @@ -262,12 +262,7 @@ class CurrentPreset { } } - // position = 0 -> first spot - // position = N -> last - // position = -1 -> delete - // To duplicate, set preset_num to -1 - void SaveAt(int position) { - LOCK_SD(true); + void SaveAtLocked(int position) { FileReader f, out; if (!OpenPresets(&f, "presets.ini")) { if (!UpdateINI()) CreateINI(); @@ -301,6 +296,15 @@ class CurrentPreset { out.Close(); UpdateINI(); preset_num = position; + } + + // position = 0 -> first spot + // position = N -> last + // position = -1 -> delete + // To duplicate, set preset_num to -1 + void SaveAt(int position) { + LOCK_SD(true); + SaveAtLocked(position); LOCK_SD(false); }