Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions eos/saveddata/fit.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import datetime
import time
from contextlib import contextmanager
from copy import deepcopy
from itertools import chain
from math import ceil, log, sqrt
Expand Down Expand Up @@ -67,6 +68,22 @@ class Fit:

PEAK_RECHARGE = 0.25

# When > 0, __resetDependentCalcs does not mark projection victims stale.
# Sequential full recalcs for mutually-projected fits (e.g. graph) would
# otherwise set victim.calculated = False without clearing them; the next
# PROJECTED pass then runs clear() and wipes that fit after it was just
# calculated correctly.
_suspendVictimCalcResetDepth = 0

@classmethod
@contextmanager
def suspendVictimCalcReset(cls):
cls._suspendVictimCalcResetDepth += 1
try:
yield
finally:
cls._suspendVictimCalcResetDepth -= 1

def __init__(self, ship=None, name=""):
"""Initialize a fit from the program"""
self.__ship = None
Expand Down Expand Up @@ -973,6 +990,8 @@ def __runCommandBoosts(self, runTime="normal"):

def __resetDependentCalcs(self):
self.calculated = False
if Fit._suspendVictimCalcResetDepth > 0:
return
for value in list(self.projectedOnto.values()):
if value.victim_fit: # removing a self-projected fit causes victim fit to be None. @todo: look into why. :3
value.victim_fit.calculated = False
Expand Down Expand Up @@ -1107,6 +1126,8 @@ def calculateModifiedAttributes(self, targetFit=None, type=CalcType.LOCAL):
# tabs. See GH issue 1193
if type == CalcType.COMMAND and targetFit in self.commandFits:
pyfalog.debug("{} is in the command listing for COMMAND ({}), do not mark self as calculated (recursive)".format(repr(targetFit), repr(self)))
elif type == CalcType.PROJECTED:
pyfalog.debug("{} is projecting onto {} (PROJECTED), do not mark self as calculated (not a full local calc)".format(repr(self), repr(targetFit)))
else:
self.__calculated = True

Expand Down