From 744fce2e8269d7de644e25e7449bc44813f49011 Mon Sep 17 00:00:00 2001 From: DarkPhoenix Date: Sat, 29 Jun 2019 10:31:21 +0300 Subject: [PATCH] Make it obvious that we're clearning cache by fitID --- gui/builtinGraphs/base.py | 12 ++++++------ gui/builtinGraphs/fitWarpTime.py | 4 ++-- gui/graphFrame/frame.py | 6 +++--- gui/graphFrame/lists.py | 2 +- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/gui/builtinGraphs/base.py b/gui/builtinGraphs/base.py index 83dfa775a..702d8a828 100644 --- a/gui/builtinGraphs/base.py +++ b/gui/builtinGraphs/base.py @@ -85,14 +85,14 @@ class FitGraph(metaclass=ABCMeta): fitCache[(ySpec, xSpec)] = plotData return plotData - def clearCache(self, key=None): - if key is None: + def clearCache(self, fitID=None): + if fitID is None: self._plotCache.clear() self._calcCache.clear() - if key in self._plotCache: - del self._plotCache[key] - if key in self._calcCache: - del self._calcCache[key] + if fitID in self._plotCache: + del self._plotCache[fitID] + if fitID in self._calcCache: + del self._calcCache[fitID] # Calculation stuff def _calcPlotPoints(self, mainInput, miscInputs, xSpec, ySpec, fit, tgt): diff --git a/gui/builtinGraphs/fitWarpTime.py b/gui/builtinGraphs/fitWarpTime.py index ee2ee970e..000dbf14b 100644 --- a/gui/builtinGraphs/fitWarpTime.py +++ b/gui/builtinGraphs/fitWarpTime.py @@ -66,7 +66,7 @@ class FitWarpTimeGraph(FitGraph): def __getSubwarpSpeed(self, fit): try: - subwarpSpeed = self._calcCache[fit.ID]['cleanSubwarpSpeed'] + subwarpSpeed = self._calcCache[fit.ID] except KeyError: modStates = {} for mod in fit.modules: @@ -96,7 +96,7 @@ class FitWarpTimeGraph(FitGraph): fighter.active = False fit.calculateModifiedAttributes() subwarpSpeed = fit.ship.getModifiedItemAttr('maxVelocity') - self._calcCache[fit.ID] = {'cleanSubwarpSpeed': subwarpSpeed} + self._calcCache[fit.ID] = subwarpSpeed for projInfo, state in projFitStates.items(): projInfo.active = state for mod, state in modStates.items(): diff --git a/gui/graphFrame/frame.py b/gui/graphFrame/frame.py index 74482b1c3..033957113 100644 --- a/gui/graphFrame/frame.py +++ b/gui/graphFrame/frame.py @@ -150,7 +150,7 @@ class GraphFrame(wx.Frame): def OnFitChanged(self, event): event.Skip() - self.getView().clearCache(key=event.fitID) + self.getView().clearCache(fitID=event.fitID) self.draw() def OnGraphSwitched(self, event): @@ -168,8 +168,8 @@ class GraphFrame(wx.Frame): def getView(self): return self.graphSelection.GetClientData(self.graphSelection.GetSelection()) - def clearCache(self, key=None): - self.getView().clearCache(key=key) + def clearCache(self, fitID=None): + self.getView().clearCache(fitID=fitID) def draw(self): global mpl_version diff --git a/gui/graphFrame/lists.py b/gui/graphFrame/lists.py index 4956f23ab..02ccb6546 100644 --- a/gui/graphFrame/lists.py +++ b/gui/graphFrame/lists.py @@ -109,7 +109,7 @@ class FitList(gui.display.Display): self.fits.remove(fit) self.update(self.fits) for fit in fits: - self.graphFrame.clearCache(key=fit.ID) + self.graphFrame.clearCache(fitID=fit.ID) self.graphFrame.draw() def unbindExternalEvents(self):