From 85029f6be84494e78973352ee95b38dd1106987b Mon Sep 17 00:00:00 2001 From: blitzmann Date: Tue, 2 Dec 2014 14:52:56 -0500 Subject: [PATCH] Add mode to blanks list to avoid exception in module operations --- gui/builtinViews/fittingView.py | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/gui/builtinViews/fittingView.py b/gui/builtinViews/fittingView.py index 7f975cbac..c889f36cb 100644 --- a/gui/builtinViews/fittingView.py +++ b/gui/builtinViews/fittingView.py @@ -403,6 +403,10 @@ class FittingView(d.Display): self.mods = fit.modules[:] self.mods.sort(key=lambda mod: (slotOrder.index(mod.slot), mod.position)) + # Blanks is a list of indexes that mark non-module positions (such + # as Racks and tactical Modes. This allows us to skip over common + # module operations such as swapping, removing, copying, etc. that + # would otherwise cause complications self.blanks = [] # preliminary markers where blanks will be inserted if sFit.serviceFittingOptions["rackSlots"]: @@ -421,11 +425,13 @@ class FittingView(d.Display): self.mods.insert(x+i, Rack.buildRack(slot)) if fit.mode: - # Modes are special snowflakes and need a little more love - # Manually add mode separator and modes at the end of the modules + # Modes are special snowflakes and need a little manual loving + # We basically append the Mode rack and Mode to the modules + # while also marking their positions in the Blanks list self.blanks.append(len(self.mods)) - self.mods.insert(len(self.mods), Rack.buildRack(Slot.MODE)) - self.mods.insert(len(self.mods), fit.mode) + self.mods.append(Rack.buildRack(Slot.MODE)) + self.blanks.append(len(self.mods)) + self.mods.append(fit.mode) else: self.mods = None @@ -464,7 +470,7 @@ class FittingView(d.Display): sel = self.GetFirstSelected() contexts = [] - while sel != -1: + while sel != -1 and sel not in self.blanks: mod = self.mods[self.GetItemData(sel)] if not mod.isEmpty: srcContext = "fittingModule" @@ -558,7 +564,10 @@ class FittingView(d.Display): else: self.SetItemBackgroundColour(i, self.GetBackgroundColour()) - if i in self.blanks and sFit.serviceFittingOptions["rackSlots"] and sFit.serviceFittingOptions["rackLabels"]: + # Set rack face to bold + if isinstance(mod, Rack) and \ + sFit.serviceFittingOptions["rackSlots"] and \ + sFit.serviceFittingOptions["rackLabels"]: font.SetWeight(wx.FONTWEIGHT_BOLD) self.SetItemFont(i, font) else: