Make sure position is returned as None in case the module cannot be found on passed fit
This commit is contained in:
@@ -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):
|
||||
|
||||
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user