diff --git a/gui/builtinViewColumns/baseName.py b/gui/builtinViewColumns/baseName.py index 70d0c65a7..6939b8e21 100644 --- a/gui/builtinViewColumns/baseName.py +++ b/gui/builtinViewColumns/baseName.py @@ -55,7 +55,9 @@ class BaseName(ViewColumn): if self.projectedView: # we need a little more information for the projected view fitID = self.mainFrame.getActiveFit() - return "%dx %s (%s)" % (stuff.getProjectionInfo(fitID).amount, stuff.name, stuff.ship.item.name) + info = stuff.getProjectionInfo(fitID) + if info: + return "%dx %s (%s)" % (stuff.getProjectionInfo(fitID).amount, stuff.name, stuff.ship.item.name) else: return "%s (%s)" % (stuff.name, stuff.ship.item.name) elif isinstance(stuff, Rack): diff --git a/gui/shipBrowser.py b/gui/shipBrowser.py index 60c03153c..7570b2aa5 100644 --- a/gui/shipBrowser.py +++ b/gui/shipBrowser.py @@ -1813,6 +1813,10 @@ class FitItem(SFItem.SFBrowserItem): sFit.deleteFit(self.fitID) + # Notify other areas that a fit has been deleted + wx.PostEvent(self.mainFrame, FitRemoved(fitID=self.fitID)) + + # todo: would a simple RefreshList() work here instead of posting that a stage has been selected? if self.shipBrowser.GetActiveStage() == 5: if fit in self.shipBrowser.lastdata: # remove fit from import cache self.shipBrowser.lastdata.remove(fit) @@ -1822,8 +1826,6 @@ class FitItem(SFItem.SFBrowserItem): else: wx.PostEvent(self.shipBrowser, Stage3Selected(shipID=self.shipID)) - wx.PostEvent(self.mainFrame, FitRemoved(fitID=self.fitID)) - def MouseLeftUp(self, event): if self.dragging and self.dragged: self.OnMouseCaptureLost(event) @@ -2004,9 +2006,10 @@ class FitItem(SFItem.SFBrowserItem): if activeFit == self.fitID and not self.deleted: sFit = Fit.getInstance() fit = sFit.getFit(activeFit) - self.timestamp = fit.modifiedCoalesce - self.notes = fit.notes - self.__setToolTip() + if fit is not None: # sometimes happens when deleting fits, dunno why. + self.timestamp = fit.modifiedCoalesce + self.notes = fit.notes + self.__setToolTip() SFItem.SFBrowserItem.Refresh(self) diff --git a/service/fit.py b/service/fit.py index fed6b3349..9c66e1f9a 100644 --- a/service/fit.py +++ b/service/fit.py @@ -173,9 +173,22 @@ class Fit(object): # refresh any fits this fit is projected onto. Otherwise, if we have # already loaded those fits, they will not reflect the changes + + # A note on refreshFits: we collect the target fits in a set because + # if a target fit has the same fit for both projected and command, + # it will be refreshed first during the projected loop and throw an + # error during the command loop + refreshFits = set() for projection in fit.projectedOnto.values(): if projection.victim_fit in eos.db.saveddata_session: # GH issue #359 - eos.db.saveddata_session.refresh(projection.victim_fit) + refreshFits.add(projection.victim_fit) + + for booster in fit.boostedOnto.values(): + if booster.boosted_fit in eos.db.saveddata_session: # GH issue #359 + refreshFits.add(booster.boosted_fit) + + for fit in refreshFits: + eos.db.saveddata_session.refresh(fit) @staticmethod def copyFit(fitID): @@ -244,6 +257,9 @@ class Fit(object): return None fit = eos.db.getFit(fitID) + if fit is None: + return None + if basic: return fit