Skip to content

Commit

Permalink
make sure SD is unlocked even if we fail to save
Browse files Browse the repository at this point in the history
  • Loading branch information
profezzorn committed Jun 8, 2020
1 parent 8f0f45f commit bfef192
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions common/current_preset.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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);
}

Expand Down

0 comments on commit bfef192

Please sign in to comment.