Make some extra logging statements and stuff to troubleshoot fit deletion bugs (#1199)
This commit is contained in:
@@ -20,6 +20,7 @@
|
||||
|
||||
# noinspection PyPackageRequirements
|
||||
import wx
|
||||
from logbook import Logger
|
||||
from eos.saveddata.cargo import Cargo
|
||||
from eos.saveddata.implant import Implant
|
||||
from eos.saveddata.drone import Drone
|
||||
@@ -30,6 +31,8 @@ from service.fit import Fit as FitSvc
|
||||
from gui.viewColumn import ViewColumn
|
||||
import gui.mainFrame
|
||||
|
||||
pyfalog = Logger(__name__)
|
||||
|
||||
|
||||
class BaseName(ViewColumn):
|
||||
name = "Base Name"
|
||||
@@ -56,8 +59,13 @@ class BaseName(ViewColumn):
|
||||
# we need a little more information for the projected view
|
||||
fitID = self.mainFrame.getActiveFit()
|
||||
info = stuff.getProjectionInfo(fitID)
|
||||
|
||||
if info:
|
||||
return "%dx %s (%s)" % (stuff.getProjectionInfo(fitID).amount, stuff.name, stuff.ship.item.name)
|
||||
|
||||
pyfalog.warning("Projected View trying to display things that aren't there. stuff: {}, info: {}", repr(stuff),
|
||||
info)
|
||||
return "<unknown>"
|
||||
else:
|
||||
return "%s (%s)" % (stuff.name, stuff.ship.item.name)
|
||||
elif isinstance(stuff, Rack):
|
||||
|
||||
@@ -278,7 +278,9 @@ class FittingView(d.Display):
|
||||
We also refresh the fit of the new current page in case
|
||||
delete fit caused change in stats (projected)
|
||||
"""
|
||||
pyfalog.debug("FittingView::fitRemoved")
|
||||
if event.fitID == self.getActiveFit():
|
||||
pyfalog.debug(" Deleted fit is currently active")
|
||||
self.parent.DeletePage(self.parent.GetPageIndex(self))
|
||||
|
||||
try:
|
||||
@@ -287,7 +289,7 @@ class FittingView(d.Display):
|
||||
sFit.refreshFit(self.getActiveFit())
|
||||
wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=self.activeFitID))
|
||||
except wx._core.PyDeadObjectError:
|
||||
pyfalog.error("Caught dead object")
|
||||
pyfalog.warning("Caught dead object")
|
||||
pass
|
||||
|
||||
event.Skip()
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
|
||||
# noinspection PyPackageRequirements
|
||||
import wx
|
||||
from logbook import Logger
|
||||
import gui.display as d
|
||||
import gui.globalEvents as GE
|
||||
import gui.droneView
|
||||
@@ -31,6 +32,8 @@ from eos.saveddata.drone import Drone as es_Drone
|
||||
from eos.saveddata.fighter import Fighter as es_Fighter
|
||||
from eos.saveddata.module import Module as es_Module
|
||||
|
||||
pyfalog = Logger(__name__)
|
||||
|
||||
|
||||
class DummyItem(object):
|
||||
def __init__(self, txt):
|
||||
@@ -174,6 +177,7 @@ class ProjectedView(d.Display):
|
||||
def fitChanged(self, event):
|
||||
sFit = Fit.getInstance()
|
||||
fit = sFit.getFit(event.fitID)
|
||||
pyfalog.debug("ProjectedView::fitChanged: {}", repr(fit))
|
||||
|
||||
self.Parent.Parent.DisablePage(self, not fit or fit.isStructure)
|
||||
|
||||
@@ -186,6 +190,7 @@ class ProjectedView(d.Display):
|
||||
|
||||
stuff = []
|
||||
if fit is not None:
|
||||
pyfalog.debug(" Collecting list of stuff to display in ProjectedView")
|
||||
self.modules = fit.projectedModules[:]
|
||||
self.drones = fit.projectedDrones[:]
|
||||
self.fighters = fit.projectedFighters[:]
|
||||
|
||||
@@ -1811,6 +1811,11 @@ class FitItem(SFItem.SFBrowserItem):
|
||||
sFit = Fit.getInstance()
|
||||
fit = sFit.getFit(self.fitID)
|
||||
|
||||
# need to delete from import cache before actually deleting fit
|
||||
if self.shipBrowser.GetActiveStage() == 5:
|
||||
if fit in self.shipBrowser.lastdata: # remove fit from import cache
|
||||
self.shipBrowser.lastdata.remove(fit)
|
||||
|
||||
sFit.deleteFit(self.fitID)
|
||||
|
||||
# Notify other areas that a fit has been deleted
|
||||
@@ -1818,8 +1823,6 @@ class FitItem(SFItem.SFBrowserItem):
|
||||
|
||||
# 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)
|
||||
wx.PostEvent(self.shipBrowser, ImportSelected(fits=self.shipBrowser.lastdata))
|
||||
elif self.shipBrowser.GetActiveStage() == 4:
|
||||
wx.PostEvent(self.shipBrowser, SearchSelected(text=self.shipBrowser.navpanel.lastSearch, back=True))
|
||||
|
||||
@@ -166,10 +166,8 @@ class Fit(object):
|
||||
|
||||
@staticmethod
|
||||
def deleteFit(fitID):
|
||||
pyfalog.debug("Deleting fit for fit ID: {0}", fitID)
|
||||
fit = eos.db.getFit(fitID)
|
||||
|
||||
eos.db.remove(fit)
|
||||
pyfalog.debug("Fit::deleteFit - Deleting fit: {}", fit)
|
||||
|
||||
# refresh any fits this fit is projected onto. Otherwise, if we have
|
||||
# already loaded those fits, they will not reflect the changes
|
||||
@@ -180,16 +178,21 @@ class Fit(object):
|
||||
# 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
|
||||
if projection.victim_fit != fit and projection.victim_fit in eos.db.saveddata_session: # GH issue #359
|
||||
refreshFits.add(projection.victim_fit)
|
||||
|
||||
for booster in fit.boostedOnto.values():
|
||||
if booster.boosted_fit in eos.db.saveddata_session: # GH issue #359
|
||||
if booster.boosted_fit != fit and booster.boosted_fit in eos.db.saveddata_session: # GH issue #359
|
||||
refreshFits.add(booster.boosted_fit)
|
||||
|
||||
eos.db.saveddata_session.delete(fit)
|
||||
|
||||
pyfalog.debug(" Need to refresh {} fits: {}", len(refreshFits), refreshFits)
|
||||
for fit in refreshFits:
|
||||
eos.db.saveddata_session.refresh(fit)
|
||||
|
||||
eos.db.saveddata_session.commit()
|
||||
|
||||
@staticmethod
|
||||
def copyFit(fitID):
|
||||
pyfalog.debug("Creating copy of fit ID: {0}", fitID)
|
||||
|
||||
Reference in New Issue
Block a user