diff --git a/gui/fitCommands/calc/module/localAdd.py b/gui/fitCommands/calc/module/localAdd.py index 8f9e1416e..48ff33b32 100644 --- a/gui/fitCommands/calc/module/localAdd.py +++ b/gui/fitCommands/calc/module/localAdd.py @@ -54,6 +54,9 @@ class CalcAddLocalModuleCommand(wx.Command): eos.db.commit() return False self.savedPosition = fit.modules.index(newMod) + # 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 self.commit: diff --git a/gui/fitCommands/calc/module/localChangeStates.py b/gui/fitCommands/calc/module/localChangeStates.py index 2cf643f42..0f7161632 100644 --- a/gui/fitCommands/calc/module/localChangeStates.py +++ b/gui/fitCommands/calc/module/localChangeStates.py @@ -46,6 +46,9 @@ class CalcChangeLocalModuleStatesCommand(wx.Command): mod.state = proposedState if not changed: return False + # 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, mainMod) eos.db.commit() diff --git a/gui/fitCommands/calc/module/localClone.py b/gui/fitCommands/calc/module/localClone.py index 031dce5ea..503a1df41 100644 --- a/gui/fitCommands/calc/module/localClone.py +++ b/gui/fitCommands/calc/module/localClone.py @@ -37,6 +37,9 @@ class CalcCloneLocalModuleCommand(wx.Command): pyfalog.warning('Failed to replace module') eos.db.commit() return False + # 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, copyMod) eos.db.commit() diff --git a/gui/fitCommands/calc/module/localRemove.py b/gui/fitCommands/calc/module/localRemove.py index 35c98a62a..5773c3eaf 100644 --- a/gui/fitCommands/calc/module/localRemove.py +++ b/gui/fitCommands/calc/module/localRemove.py @@ -30,6 +30,9 @@ class CalcRemoveLocalModulesCommand(wx.Command): self.savedModInfos[position] = ModuleInfo.fromModule(mod) fit.modules.free(position) + # 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, None) if self.commit: diff --git a/gui/fitCommands/calc/module/localReplace.py b/gui/fitCommands/calc/module/localReplace.py index 6627baec8..067a92294 100644 --- a/gui/fitCommands/calc/module/localReplace.py +++ b/gui/fitCommands/calc/module/localReplace.py @@ -56,6 +56,9 @@ class CalcReplaceLocalModuleCommand(wx.Command): pyfalog.warning('Failed to replace in list') self.Undo() return False + # 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 self.commit: