From 75642929e32c0fc1610378abf2e997cfa12c7318 Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Tue, 28 Feb 2023 18:01:13 -0500 Subject: [PATCH] Move cache-reset ctx mngr to parent type: `FlowGraphics.reset_cache()` --- piker/ui/_curve.py | 16 ++++++++++------ piker/ui/_ohlc.py | 2 +- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/piker/ui/_curve.py b/piker/ui/_curve.py index 052a94a3..091bbad0 100644 --- a/piker/ui/_curve.py +++ b/piker/ui/_curve.py @@ -163,6 +163,16 @@ class FlowGraphic(pg.GraphicsObject): return None + @cm + def reset_cache(self) -> None: + self.setCacheMode(QtWidgets.QGraphicsItem.NoCache) + try: + log.debug(f'{self._name} -> CACHE DISABLE') + yield + finally: + log.debug(f'{self._name} -> CACHE ENABLE') + self.setCacheMode(self.cache_mode) + class Curve(FlowGraphic): ''' @@ -251,12 +261,6 @@ class Curve(FlowGraphic): self.fast_path.clear() # self.fast_path = None - @cm - def reset_cache(self) -> None: - self.setCacheMode(QtWidgets.QGraphicsItem.NoCache) - yield - self.setCacheMode(QGraphicsItem.DeviceCoordinateCache) - def boundingRect(self): ''' Compute and then cache our rect. diff --git a/piker/ui/_ohlc.py b/piker/ui/_ohlc.py index 25ebb591..f3eb12b0 100644 --- a/piker/ui/_ohlc.py +++ b/piker/ui/_ohlc.py @@ -93,7 +93,7 @@ class BarItems(FlowGraphic): ''' # XXX: causes this weird jitter bug when click-drag panning # where the path curve will awkwardly flicker back and forth? - cache_mode: int = QGraphicsItem.NoCache + # cache_mode: int = QGraphicsItem.NoCache def __init__( self,