Skip to content

Handle preset deletion asynchronously for consistency with preset saving #4348

@david-hogberg

Description

@david-hogberg

Is your feature request related to a problem? Please describe.
I'm developing a BLE mod for wled which works fine for commands except preset/playlist deletion (device crashes). I then noticed that presets are deleted using immediate file operations rather than asynchronously using flags, which is how presets are saved for example. Same for API calls. Is this there a reason for this or a bug? Issue solved if I move deletion to be handled later in the main loop (see below).

Deletion still works fine using wifi, but thought it might be a general stability improvement anyway.

Describe the solution you'd like
In presets.cpp: Instead of directly initiating file operations in deletePreset(index), called from deserializeState, set a flag presetToDelete = index that's picked up in handlePresets(). Something like this:

void handlePresets()
{
  if (presetToDelete) {
    doDeleteState();
    return;
  }

  if (presetToSave) {
    doSaveState();
    return;
  }
  
  ...
  
}

Adds consistent behaviour between preset deletion and saving, and prevents potential blocking operations during preset deletion.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions