[fix] preventing to load null application null icon

This commit is contained in:
Vinícius Moreira
2019-12-23 13:23:51 -03:00
parent 6984a34d25
commit f6b380bf78

View File

@@ -203,20 +203,22 @@ class AppsTable(QTableWidget):
icon_was_cached = False
pixmap = QPixmap()
pixmap.loadFromData(icon_bytes)
icon = QIcon(pixmap)
icon_data = {'icon': icon, 'bytes': icon_bytes}
self.icon_cache.add(icon_url, icon_data)
for idx, app in enumerate(self.window.pkgs):
if app.model.icon_url == icon_url:
col_name = self.item(idx, 0)
col_name.setIcon(icon_data['icon'])
if not pixmap.isNull():
icon = QIcon(pixmap)
icon_data = {'icon': icon, 'bytes': icon_bytes}
self.icon_cache.add(icon_url, icon_data)
if self.disk_cache and app.model.supports_disk_cache() and app.model.get_disk_icon_path():
if not icon_was_cached or not os.path.exists(app.model.get_disk_icon_path()):
self.window.manager.cache_to_disk(pkg=app.model, icon_bytes=icon_data['bytes'], only_icon=True)
if icon_data:
for idx, app in enumerate(self.window.pkgs):
if app.model.icon_url == icon_url:
col_name = self.item(idx, 0)
col_name.setIcon(icon_data['icon'])
if self.disk_cache and app.model.supports_disk_cache() and app.model.get_disk_icon_path():
if not icon_was_cached or not os.path.exists(app.model.get_disk_icon_path()):
self.window.manager.cache_to_disk(pkg=app.model, icon_bytes=icon_data['bytes'], only_icon=True)
def update_pkgs(self, pkg_views: List[PackageView], update_check_enabled: bool = True):
self.setRowCount(len(pkg_views) if pkg_views else 0)