Do not crash when facing unknown module in saved fit

This commit is contained in:
DarkPhoenix
2019-05-03 02:27:03 +03:00
parent b121085271
commit cfffa1d99d
14 changed files with 125 additions and 63 deletions

View File

@@ -36,7 +36,7 @@ class CalcAddBoosterCommand(wx.Command):
if self.newPosition is not None:
try:
fit.boosters.insert(self.newPosition, newBooster)
fit.boosters.insert(self.newPosition, newBooster, raiseFailure=True)
except HandledListActionError:
pyfalog.warning('Failed to insert to list')
cmd = CalcAddBoosterCommand(
@@ -48,7 +48,7 @@ class CalcAddBoosterCommand(wx.Command):
return False
else:
try:
fit.boosters.append(newBooster)
fit.boosters.append(newBooster, raiseFailure=True)
except HandledListActionError:
pyfalog.warning('Failed to append to list')
cmd = CalcAddBoosterCommand(

View File

@@ -26,7 +26,7 @@ class CalcAddCargoCommand(wx.Command):
else:
cargo = self.cargoInfo.toCargo()
try:
fit.cargo.append(cargo)
fit.cargo.append(cargo, raiseFailure=True)
except HandledListActionError:
pyfalog.warning('Failed to append to list')
if self.commit:

View File

@@ -51,7 +51,7 @@ class CalcAddLocalDroneCommand(wx.Command):
pyfalog.warning('Drone does not fit')
return False
try:
fit.drones.append(drone)
fit.drones.append(drone, raiseFailure=True)
except HandledListActionError:
pyfalog.warning('Failed to append to list')
if self.commit:

View File

@@ -49,7 +49,7 @@ class CalcRemoveLocalDroneCommand(wx.Command):
if drone is None:
return False
try:
fit.drones.insert(self.position, drone)
fit.drones.insert(self.position, drone, raiseFailure=True)
except HandledListActionError:
pyfalog.warning('Failed to insert to list')
if self.commit:

View File

@@ -44,7 +44,7 @@ class CalcAddProjectedDroneCommand(wx.Command):
pyfalog.debug('Drone is not projectable')
return False
try:
fit.projectedDrones.append(drone)
fit.projectedDrones.append(drone, raiseFailure=True)
except HandledListActionError:
pyfalog.warning('Failed to append to list')
if self.commit:

View File

@@ -42,7 +42,7 @@ class CalcAddLocalFighterCommand(wx.Command):
if self.position is None:
try:
fit.fighters.append(fighter)
fit.fighters.append(fighter, raiseFailure=True)
except HandledListActionError:
pyfalog.warning('Failed to append to list')
if self.commit:
@@ -51,7 +51,7 @@ class CalcAddLocalFighterCommand(wx.Command):
self.position = fit.fighters.index(fighter)
else:
try:
fit.fighters.insert(self.position, fighter)
fit.fighters.insert(self.position, fighter, raiseFailure=True)
except HandledListActionError:
pyfalog.warning('Failed to insert to list')
if self.commit:

View File

@@ -26,14 +26,14 @@ class CalcAddProjectedFighterCommand(wx.Command):
fit = Fit.getInstance().getFit(self.fitID)
if self.position is not None:
try:
fit.projectedFighters.insert(self.position, fighter)
fit.projectedFighters.insert(self.position, fighter, raiseFailure=True)
except HandledListActionError:
if self.commit:
eos.db.commit()
return False
else:
try:
fit.projectedFighters.append(fighter)
fit.projectedFighters.append(fighter, raiseFailure=True)
except HandledListActionError:
if self.commit:
eos.db.commit()

View File

@@ -36,7 +36,7 @@ class CalcAddImplantCommand(wx.Command):
if self.newPosition is not None:
try:
fit.implants.insert(self.newPosition, newImplant)
fit.implants.insert(self.newPosition, newImplant, raiseFailure=True)
except HandledListActionError:
pyfalog.warning('Failed to insert to list')
cmd = CalcAddImplantCommand(
@@ -48,7 +48,7 @@ class CalcAddImplantCommand(wx.Command):
return False
else:
try:
fit.implants.append(newImplant)
fit.implants.append(newImplant, raiseFailure=True)
except HandledListActionError:
pyfalog.warning('Failed to append to list')
cmd = CalcAddImplantCommand(

View File

@@ -56,7 +56,7 @@ class CalcAddLocalModuleCommand(wx.Command):
pyfalog.warning('Module does not fit')
return False
try:
fit.modules.append(newMod)
fit.modules.append(newMod, raiseFailure=True)
except HandledListActionError:
pyfalog.warning('Failed to append to list')
if self.commit:

View File

@@ -32,7 +32,7 @@ class CalcCloneLocalModuleCommand(wx.Command):
if not fit.modules[self.dstPosition].isEmpty:
return False
try:
fit.modules.replace(self.dstPosition, copyMod)
fit.modules.replace(self.dstPosition, copyMod, raiseFailure=True)
except HandledListActionError:
pyfalog.warning('Failed to replace module')
eos.db.commit()

View File

@@ -54,7 +54,7 @@ class CalcReplaceLocalModuleCommand(wx.Command):
self.Undo()
return False
try:
fit.modules.replace(self.position, newMod)
fit.modules.replace(self.position, newMod, raiseFailure=True)
except HandledListActionError:
pyfalog.warning('Failed to replace in list')
self.Undo()
@@ -88,7 +88,7 @@ class CalcReplaceLocalModuleCommand(wx.Command):
return False
fit.modules.free(self.position)
try:
fit.modules.replace(self.position, oldMod)
fit.modules.replace(self.position, oldMod, raiseFailure=True)
except HandledListActionError:
pyfalog.warning('Failed to replace in list')
self.Do()

View File

@@ -34,14 +34,14 @@ class CalcSwapLocalModuleCommand(wx.Command):
fit.modules.free(position1)
fit.modules.free(position2)
try:
fit.modules.replace(position2, mod1)
fit.modules.replace(position2, mod1, raiseFailure=True)
except HandledListActionError:
fit.modules.replace(position1, mod1)
fit.modules.replace(position2, mod2)
eos.db.commit()
return False
try:
fit.modules.replace(position1, mod2)
fit.modules.replace(position1, mod2, raiseFailure=True)
except HandledListActionError:
fit.modules.free(position2)
fit.modules.replace(position1, mod1)

View File

@@ -40,14 +40,14 @@ class CalcAddProjectedModuleCommand(wx.Command):
if self.newPosition is not None:
try:
fit.projectedModules.insert(self.newPosition, newMod)
fit.projectedModules.insert(self.newPosition, newMod, raiseFailure=True)
except HandledListActionError:
if self.commit:
eos.db.commit()
return False
else:
try:
fit.projectedModules.append(newMod)
fit.projectedModules.append(newMod, raiseFailure=True)
except HandledListActionError:
if self.commit:
eos.db.commit()