Make sure position is returned as None in case the module cannot be found on passed fit

This commit is contained in:
DarkPhoenix
2019-04-17 22:37:44 +03:00
parent f4f92b0821
commit 4c04fd93ae
2 changed files with 6 additions and 3 deletions

View File

@@ -246,8 +246,12 @@ class Module(HandledItem, HandledCharge, ItemAttrShortcut, ChargeAttrShortcut):
# is set by sqlalchemy during flush
fit = fit if fit is not None else self.owner
if fit:
return fit.modules.index(self) if not self.isProjected else fit.projectedModules.index(self)
container = fit.projectedModules if self.isProjected else fit.modules
try:
return container.index(self)
except ValueError:
return None
return None
@property
def isProjected(self):

View File

@@ -50,7 +50,6 @@ class CalcReplaceLocalModuleCommand(wx.Command):
pyfalog.warning('Invalid charge')
self.Undo()
return False
newMod.owner = fit
try:
fit.modules.replace(self.position, newMod)
except HandledListActionError: