Tons of error checking and cleanup
getIconsByMarketGroup() was badly broken. I've added various error checking routines and fixed a runaway memory allocation freeze in the event that no icons can be found. The cause of that problem remains, however. Still working on it.
This commit is contained in:
@@ -161,7 +161,10 @@ class MarketTree(wx.TreeCtrl):
|
||||
if sMkt.marketGroupValidityCheck(childMktGrp) is False:
|
||||
continue
|
||||
iconId = self.addImage(sMkt.getIconByMarketGroup(childMktGrp))
|
||||
childId = self.AppendItem(root, childMktGrp.name, iconId, data=wx.TreeItemData(childMktGrp.ID))
|
||||
try:
|
||||
childId = self.AppendItem(root, childMktGrp.name, iconId, data=wx.TreeItemData(childMktGrp.ID))
|
||||
except:
|
||||
continue
|
||||
if sMkt.marketGroupHasTypesCheck(childMktGrp) is False:
|
||||
self.AppendItem(childId, "dummy")
|
||||
|
||||
|
||||
@@ -531,10 +531,10 @@ class Market():
|
||||
|
||||
def marketGroupHasTypesCheck(self, mg):
|
||||
"""If market group has any items, return true"""
|
||||
if mg.ID in self.ITEMS_FORCEDMARKETGROUP_R:
|
||||
if mg and mg.ID in self.ITEMS_FORCEDMARKETGROUP_R:
|
||||
return True
|
||||
elif mg.hasTypes:
|
||||
return True
|
||||
elif not mg.hasTypes:
|
||||
return False
|
||||
elif len(mg.items) > 0:
|
||||
return True
|
||||
else:
|
||||
@@ -554,21 +554,20 @@ class Market():
|
||||
if mg.icon:
|
||||
return mg.icon.iconFile
|
||||
else:
|
||||
if self.marketGroupHasTypesCheck(mg):
|
||||
while mg and not mg.hasTypes:
|
||||
mg = mg.parent
|
||||
if not mg:
|
||||
return ""
|
||||
elif self.marketGroupHasTypesCheck(mg):
|
||||
# Do not request variations to make process faster
|
||||
# Pick random item and use its icon
|
||||
items = self.getItemsByMarketGroup(mg, vars=False)
|
||||
if len(items) > 0:
|
||||
item = items.pop()
|
||||
return item.icon.iconFile if item.icon else ""
|
||||
else:
|
||||
return ""
|
||||
item = items.pop()
|
||||
return item.icon.iconFile if item.icon else ""
|
||||
elif self.getMarketGroupChildren(mg) > 0:
|
||||
mktGroups = self.getIconByMarketGroup(self.getMarketGroupChildren(mg))
|
||||
if len(mktGroups) > 0:
|
||||
return mktGroups.pop()
|
||||
else:
|
||||
return ""
|
||||
kids = self.getMarketGroupChildren(mg)
|
||||
size = len(self.getIconByMarketGroup(kids))
|
||||
return mktGroups.pop() if size > 0 else ""
|
||||
else:
|
||||
return ""
|
||||
|
||||
|
||||
Reference in New Issue
Block a user