Skip to content

Commit 0642ee4

Browse files
authored
Merge pull request #128 from martinRenou/hold_canvas
Clean canvas state when using hold_canvas
2 parents ba83e00 + e58f496 commit 0642ee4

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

ipycanvas/canvas.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -588,7 +588,6 @@ def flush(self):
588588

589589
self.send(self._commands_cache, self._buffers_cache)
590590

591-
self.caching = False
592591
self._commands_cache = []
593592
self._buffers_cache = []
594593

@@ -808,6 +807,11 @@ def hold_canvas(canvas):
808807
Args:
809808
canvas (ipycanvas.canvas.Canvas): The canvas widget on which to hold the commands
810809
"""
810+
orig_caching = canvas.caching
811+
811812
canvas.caching = True
812813
yield
813814
canvas.flush()
815+
816+
if not orig_caching:
817+
canvas.caching = False

0 commit comments

Comments
 (0)