fix for random crashes on changing presets (UI)

Segments are created/deleted on-the-fly; it seems that "local leds" buffers did not follow properly.
* revise segment copy/move constructors
* de-optimize use of local leds (as they need to be re-allocated when segment size changes)
* minor stability improvements
This commit is contained in:
Frank
2023-07-08 22:40:43 +02:00
parent a45306b141
commit c64f74a611
4 changed files with 54 additions and 32 deletions

View File

@@ -48,6 +48,7 @@
static bool inDeepCall = false; // WLEDMM needed so that recursive deserializeSegment() does not remove locks too early
// WLEDMM caution - this function may run outside of arduino loop context (async_tcp with priority=3)
bool deserializeSegment(JsonObject elem, byte it, byte presetId)
{
const bool iAmGroot = !inDeepCall; // WLEDMM will only be true if this is the toplevel of the recursion.
@@ -368,6 +369,7 @@ bool deserializeSegment(JsonObject elem, byte it, byte presetId)
// deserializes WLED state (fileDoc points to doc object if called from web server)
// presetId is non-0 if called from handlePreset()
// WLEDMM caution - this function may run outside of arduino loop context (async_tcp with priority=3)
bool deserializeState(JsonObject root, byte callMode, byte presetId)
{
const bool iAmGroot = !inDeepCall; // WLEDMM will only be true if this is the toplevel of the recursion.
@@ -419,6 +421,10 @@ bool deserializeState(JsonObject root, byte callMode, byte presetId)
}
}
#ifdef ARDUINO_ARCH_ESP32
delay(2); // WLEDMM experimental - de-serialize takes time, so allow other tasks to run
#endif
// WLEDMM: before changing strip, make sure our strip is _not_ servicing effects in parallel
suspendStripService = true; // temporarily lock out strip updates
if (strip.isServicing()) {