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
|
# is set by sqlalchemy during flush
|
||||||
fit = fit if fit is not None else self.owner
|
fit = fit if fit is not None else self.owner
|
||||||
if fit:
|
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
|
@property
|
||||||
def isProjected(self):
|
def isProjected(self):
|
||||||
|
|||||||
@@ -50,7 +50,6 @@ class CalcReplaceLocalModuleCommand(wx.Command):
|
|||||||
pyfalog.warning('Invalid charge')
|
pyfalog.warning('Invalid charge')
|
||||||
self.Undo()
|
self.Undo()
|
||||||
return False
|
return False
|
||||||
newMod.owner = fit
|
|
||||||
try:
|
try:
|
||||||
fit.modules.replace(self.position, newMod)
|
fit.modules.replace(self.position, newMod)
|
||||||
except HandledListActionError:
|
except HandledListActionError:
|
||||||
|
|||||||
Reference in New Issue
Block a user