From 359d46c3e1ff4a4177e0d2ce3e3a84498506af4f Mon Sep 17 00:00:00 2001 From: Damian Schneider Date: Thu, 2 Oct 2025 20:06:01 +0200 Subject: [PATCH] Bugfix for gif playback and segment destruction, 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.cpp | 3 ++- wled00/FX.h | 3 +++ wled00/FX_fcn.cpp | 9 +++++++++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/wled00/FX.cpp b/wled00/FX.cpp index 837fb40e..c8b44a18 100644 --- a/wled00/FX.cpp +++ b/wled00/FX.cpp @@ -135,7 +135,8 @@ uint16_t mode_copy_segment(void) { SEGMENT.fadeToBlackBy(5); // fade out return FRAMETIME; } - Segment sourcesegment = strip.getSegment(sourceid); + Segment& sourcesegment = strip.getSegment(sourceid); + if (sourcesegment.isActive()) { uint32_t sourcecolor; uint32_t destcolor; diff --git a/wled00/FX.h b/wled00/FX.h index 775607cc..250df264 100644 --- a/wled00/FX.h +++ b/wled00/FX.h @@ -625,6 +625,9 @@ class Segment { DEBUGFX_PRINTLN(); #endif clearName(); + #ifdef WLED_ENABLE_GIF + endImagePlayback(this); + #endif deallocateData(); p_free(pixels); } diff --git a/wled00/FX_fcn.cpp b/wled00/FX_fcn.cpp index 9ef64631..2d98dc04 100644 --- a/wled00/FX_fcn.cpp +++ b/wled00/FX_fcn.cpp @@ -448,6 +448,9 @@ void Segment::setGeometry(uint16_t i1, uint16_t i2, uint8_t grp, uint8_t spc, ui // apply change immediately if (i2 <= i1) { //disable segment + #ifdef WLED_ENABLE_GIF + endImagePlayback(this); + #endif deallocateData(); p_free(pixels); pixels = nullptr; @@ -466,6 +469,9 @@ void Segment::setGeometry(uint16_t i1, uint16_t i2, uint8_t grp, uint8_t spc, ui #endif // safety check if (start >= stop || startY >= stopY) { + #ifdef WLED_ENABLE_GIF + endImagePlayback(this); + #endif deallocateData(); p_free(pixels); pixels = nullptr; @@ -479,6 +485,9 @@ void Segment::setGeometry(uint16_t i1, uint16_t i2, uint8_t grp, uint8_t spc, ui pixels = static_cast(allocate_buffer(length() * sizeof(uint32_t), BFRALLOC_PREFER_PSRAM | BFRALLOC_NOBYTEACCESS)); if (!pixels) { DEBUGFX_PRINTLN(F("!!! Not enough RAM for pixel buffer !!!")); + #ifdef WLED_ENABLE_GIF + endImagePlayback(this); + #endif deallocateData(); errorFlag = ERR_NORAM_PX; stop = 0;