Skip to content

Commit 3562fa2

Browse files
authored
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!
2 parents 2b73a34 + 359d46c commit 3562fa2

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed

wled00/FX.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,8 @@ uint16_t mode_copy_segment(void) {
135135
SEGMENT.fadeToBlackBy(5); // fade out
136136
return FRAMETIME;
137137
}
138-
Segment sourcesegment = strip.getSegment(sourceid);
138+
Segment& sourcesegment = strip.getSegment(sourceid);
139+
139140
if (sourcesegment.isActive()) {
140141
uint32_t sourcecolor;
141142
uint32_t destcolor;

wled00/FX.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -625,6 +625,9 @@ class Segment {
625625
DEBUGFX_PRINTLN();
626626
#endif
627627
clearName();
628+
#ifdef WLED_ENABLE_GIF
629+
endImagePlayback(this);
630+
#endif
628631
deallocateData();
629632
p_free(pixels);
630633
}

wled00/FX_fcn.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -448,6 +448,9 @@ void Segment::setGeometry(uint16_t i1, uint16_t i2, uint8_t grp, uint8_t spc, ui
448448

449449
// apply change immediately
450450
if (i2 <= i1) { //disable segment
451+
#ifdef WLED_ENABLE_GIF
452+
endImagePlayback(this);
453+
#endif
451454
deallocateData();
452455
p_free(pixels);
453456
pixels = nullptr;
@@ -466,6 +469,9 @@ void Segment::setGeometry(uint16_t i1, uint16_t i2, uint8_t grp, uint8_t spc, ui
466469
#endif
467470
// safety check
468471
if (start >= stop || startY >= stopY) {
472+
#ifdef WLED_ENABLE_GIF
473+
endImagePlayback(this);
474+
#endif
469475
deallocateData();
470476
p_free(pixels);
471477
pixels = nullptr;
@@ -479,6 +485,9 @@ void Segment::setGeometry(uint16_t i1, uint16_t i2, uint8_t grp, uint8_t spc, ui
479485
pixels = static_cast<uint32_t*>(allocate_buffer(length() * sizeof(uint32_t), BFRALLOC_PREFER_PSRAM | BFRALLOC_NOBYTEACCESS));
480486
if (!pixels) {
481487
DEBUGFX_PRINTLN(F("!!! Not enough RAM for pixel buffer !!!"));
488+
#ifdef WLED_ENABLE_GIF
489+
endImagePlayback(this);
490+
#endif
482491
deallocateData();
483492
errorFlag = ERR_NORAM_PX;
484493
stop = 0;

0 commit comments

Comments
 (0)