From e5ab0b60770aa498cc66bbca91e50588658f8815 Mon Sep 17 00:00:00 2001 From: Damian Schneider Date: Thu, 2 Oct 2025 20:40:43 +0200 Subject: [PATCH] Bugfix for gif player WRT inactive segment and bugfix in copy FX - if a segment is destroyed or turned inactive, disable the gif player: only one gif player instance can run at a time, if a inactive or destroyed segment uses it, the effect is broken for other segments. - copy FX ironically copied the source segment on each call, should use reference not a copy! --- wled00/FX.h | 7 +++++++ wled00/FX_fcn.cpp | 3 +++ 2 files changed, 10 insertions(+) diff --git a/wled00/FX.h b/wled00/FX.h index 32086c50..ad1fd292 100644 --- a/wled00/FX.h +++ b/wled00/FX.h @@ -16,6 +16,10 @@ bool canUseSerial(void); // WLEDMM implemented in wled_serial.cpp void strip_wait_until_idle(String whoCalledMe); // WLEDMM implemented in FX_fcn.cpp bool strip_uses_global_leds(void) __attribute__((pure)); // WLEDMM implemented in FX_fcn.cpp +#ifdef WLED_ENABLE_GIF +struct Segment; // forward declaration +void endImagePlayback(Segment *seg); // implemented in image_loader.cpp +#endif #define FASTLED_INTERNAL //remove annoying pragma messages #define USE_GET_MILLISECOND_TIMER @@ -585,6 +589,9 @@ typedef struct Segment { #ifdef ARDUINO_ARCH_ESP32 strip_wait_until_idle("~Segment()"); #endif + #ifdef WLED_ENABLE_GIF + endImagePlayback(this); + #endif if ((Segment::_globalLeds == nullptr) && !strip_uses_global_leds() && (ledsrgb != nullptr)) {free(ledsrgb); ledsrgb = nullptr;} // WLEDMM we need "!strip_uses_global_leds()" to avoid crashes (#104) if (name) { delete[] name; name = nullptr; } diff --git a/wled00/FX_fcn.cpp b/wled00/FX_fcn.cpp index 879b93a2..991ed761 100644 --- a/wled00/FX_fcn.cpp +++ b/wled00/FX_fcn.cpp @@ -542,6 +542,9 @@ void Segment::setUp(uint16_t i1, uint16_t i2, uint8_t grp, uint8_t spc, uint16_t if (stop>start) markForBlank(); //turn old segment range off // WLEDMM stop > start // toDo: check if this can be skipped when boundsUnchanged if (i2 <= i1) { //disable segment + #ifdef WLED_ENABLE_GIF + endImagePlayback(this); + #endif stop = 0; markForReset(); return;