Closed multimeric closed 1 year ago
Actually this seems to happen in any scenario where the event handler function is re-used across multiple magic classes, even when inheritance isn't involved:
from magicclass import magicclass, vfield, MagicTemplate
def _foo_changed(self) -> None:
print("Foo changed")
@magicclass
class Container:
@magicclass
class ChildA:
foo = vfield(int)
_ = foo.connect(_foo_changed)
@magicclass
class ChildB:
foo = vfield(int)
_ = foo.connect(_foo_changed)
Container().show()
Thank you @multimeric ! That might be a result of an incomplete parent-search strategy... I think I can include this bug fix in the upcoming next release in a week or so.
Note for me: Following bug might be relevant to this bug.
def _foo_changed(self, w=None) -> None:
print("Foo changed")
@magicclass
class ChildA:
foo = vfield(int)
foo.connect(_foo_changed)
a = ChildA()
a.show()
Following the docs on inheriting magicclasses, I tried to factor a common field out into a parent class, with its own self-contained logic using
@connect
. However, I've identified that, if you have two such classes that use the same parent class, you get an unusual fatal error:When you check one of the
foo
boxes, you get: