id() invalid if things disappear
This commit is contained in:
parent
bd8861f10d
commit
17395b0769
@ -452,12 +452,14 @@ class LayerV1ListBuilder:
|
|||||||
layers: List[ot.Paint]
|
layers: List[ot.Paint]
|
||||||
reusePool: Mapping[Tuple[Any, ...], int]
|
reusePool: Mapping[Tuple[Any, ...], int]
|
||||||
tuples: Mapping[int, Tuple[Any, ...]]
|
tuples: Mapping[int, Tuple[Any, ...]]
|
||||||
|
keepAlive: List[ot.Paint] # we need id to remain valid
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.slices = []
|
self.slices = []
|
||||||
self.layers = []
|
self.layers = []
|
||||||
self.reusePool = {}
|
self.reusePool = {}
|
||||||
self.tuples = {}
|
self.tuples = {}
|
||||||
|
self.keepAlive = []
|
||||||
|
|
||||||
def _paint_tuple(self, paint: ot.Paint):
|
def _paint_tuple(self, paint: ot.Paint):
|
||||||
# start simple, who even cares about cyclic graphs or interesting field types
|
# start simple, who even cares about cyclic graphs or interesting field types
|
||||||
@ -478,6 +480,7 @@ class LayerV1ListBuilder:
|
|||||||
if result is None:
|
if result is None:
|
||||||
result = _tuple_safe(paint)
|
result = _tuple_safe(paint)
|
||||||
self.tuples[id(paint)] = result
|
self.tuples[id(paint)] = result
|
||||||
|
self.keepAlive.append(paint)
|
||||||
return result
|
return result
|
||||||
|
|
||||||
def _as_tuple(self, paints: Sequence[ot.Paint]) -> Tuple[Any, ...]:
|
def _as_tuple(self, paints: Sequence[ot.Paint]) -> Tuple[Any, ...]:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user