Ensure that module-fit relationship is established before running some checks which can rely on them

This commit is contained in:
DarkPhoenix
2019-04-20 04:06:57 +03:00
parent 8c40489049
commit c3e1ec2760
5 changed files with 15 additions and 0 deletions

View File

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

View File

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

View File

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

View File

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

View File

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