Make it obvious that we're clearning cache by fitID

This commit is contained in:
DarkPhoenix
2019-06-29 10:31:21 +03:00
parent dd55493b4e
commit 744fce2e82
4 changed files with 12 additions and 12 deletions

View File

@@ -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):

View File

@@ -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():

View File

@@ -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

View File

@@ -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):