From 8c25b2b8f504d6c5612b23e739ec50a16e863cd7 Mon Sep 17 00:00:00 2001 From: DarkPhoenix Date: Wed, 15 Apr 2020 15:40:54 +0300 Subject: [PATCH] Make sure it's impossible to add extra cap boosters via dragging too --- gui/fitCommands/calc/module/localAdd.py | 4 +--- gui/fitCommands/calc/module/localReplace.py | 23 ++++++++++----------- 2 files changed, 12 insertions(+), 15 deletions(-) diff --git a/gui/fitCommands/calc/module/localAdd.py b/gui/fitCommands/calc/module/localAdd.py index 0425b25cb..8c03526a9 100644 --- a/gui/fitCommands/calc/module/localAdd.py +++ b/gui/fitCommands/calc/module/localAdd.py @@ -54,9 +54,7 @@ class CalcAddLocalModuleCommand(wx.Command): # module if the check has failed if not newMod.fits(fit): pyfalog.warning('Module does not fit') - from .localRemove import CalcRemoveLocalModulesCommand - cmd = CalcRemoveLocalModulesCommand(fitID=self.fitID, positions=[self.savedPosition], recalc=False) - cmd.Do() + self.Undo() return False self.savedStateCheckChanges = sFit.checkStates(fit, newMod) return True diff --git a/gui/fitCommands/calc/module/localReplace.py b/gui/fitCommands/calc/module/localReplace.py index 8ac67a028..95ac5924b 100644 --- a/gui/fitCommands/calc/module/localReplace.py +++ b/gui/fitCommands/calc/module/localReplace.py @@ -39,7 +39,17 @@ class CalcReplaceLocalModuleCommand(wx.Command): if newMod.slot != oldMod.slot: return False # Dummy it out in case the next bit fails - fit.modules.free(self.position) + fit.modules.replace(self.position, newMod) + if newMod not in fit.modules: + pyfalog.warning('Failed to replace in list') + self.Undo() + return False + if self.recalc: + # Need to flush because checkStates sometimes relies on module->fit + # relationship via .owner attribute, which is handled by SQLAlchemy + eos.db.flush() + sFit.recalc(fit) + self.savedStateCheckChanges = sFit.checkStates(fit, newMod) if not self.ignoreRestrictions and not newMod.fits(fit): pyfalog.warning('Module does not fit') self.Undo() @@ -52,17 +62,6 @@ class CalcReplaceLocalModuleCommand(wx.Command): pyfalog.warning('Invalid charge') self.Undo() return False - fit.modules.replace(self.position, newMod) - if newMod not in fit.modules: - pyfalog.warning('Failed to replace in list') - self.Undo() - return False - if self.recalc: - # Need to flush because checkStates sometimes relies on module->fit - # relationship via .owner attribute, which is handled by SQLAlchemy - eos.db.flush() - sFit.recalc(fit) - self.savedStateCheckChanges = sFit.checkStates(fit, newMod) return True def Undo(self):