Hi,
I've got a widget with a color fill which is bound to an RGB property that changes when a slider is moved. My issue is that after moving the slider around a lot, at some point the binding breaks and the color fill stops updating. The rest of the app continues to function fine and there is no output (including with the --debug flag). This sometimes happens almost immediately, and sometimes takes a while of moving the slider around, but I can make it happen every time.
I'm not sure how to debug the binding further so posting it here.
Here's the color fill:
<LightControlScreen>:
canvas.before:
Color:
rgb: self.lamp_state.rgb
Rectangle:
pos: self.pos
size: self.size
Here's the self.lamp_state property being bound to:
class LightControlScreen(Screen):
lamp_state = ObjectProperty(defaultvalue=LampState(), rebind=True, baseclass=LampState)
Here's the LampState rgb property being bound to, which is a ReferenceListProperty made of red, green, blue:
class LampState(EventDispatcher):
red = BoundedNumericProperty(1.0, min=0.0, max=1.0)
green = BoundedNumericProperty(1.0, min=0.0, max=1.0)
blue = BoundedNumericProperty(1.0, min=0.0, max=1.0)
rgb = ReferenceListProperty(red, green, blue)
brightness = BoundedNumericProperty(1.0, min=0.0, max=1.0)
When the slider changes, an entirely new LampState instance is created and the property is overwritten:
new_lamp_state = LampState(red=r,green=g,blue=b,brightness=self.brightness)
self.lamp_state = new_lamp_state
I verified after the binding breaks that self.lamp_state and self.lamp_state.rgb represent the new values -- the properties are getting set but the canvas just stops updating.
I did try manually calling self.canvas.ask_update() after the property set, which did not help.
The slider, by the way, is min: 0.0, max: 1.0, step: 0.01. So it doesn't change value as often as it would without step specified but still I'm guessing how fast rgb is updated could have something to do with the problem.
If anyone has any ideas of how to fix or debug it would be much appreciated. I was hoping for some way to observe and debug bindings at runtime but I'm not sure how to get there.