Fix crash when hiding a game from the Lutris view specifically.

This commit is contained in:
Daniel Johnson 2024-01-07 10:07:07 -05:00
parent 858786decd
commit 5ebebf41a6
5 changed files with 19 additions and 12 deletions

View file

@ -812,7 +812,7 @@ class Application(Gtk.Application):
"""Request installation of a game"""
if game.service and game.service != "lutris":
service = get_enabled_services()[game.service]()
db_game = ServiceGameCollection.get_game(service.id, game.appid)
db_game = service.get_service_db_game(game)
if not db_game:
logger.error("Can't find %s for %s", game.name, service.name)
return True

View file

@ -983,10 +983,6 @@ class LutrisWindow(Gtk.ApplicationWindow,
self.redraw_view()
def on_game_selection_changed(self, view, selection):
if not selection:
GLib.idle_add(self.update_revealer)
return False
game_ids = [view.get_game_id_for_path(path) for path in selection]
if not game_ids:
@ -1044,13 +1040,15 @@ class LutrisWindow(Gtk.ApplicationWindow,
def on_game_updated(self, game):
"""Updates an individual entry in the view when a game is updated"""
add_to_path_cache(game)
if game.appid and self.service:
db_game = ServiceGameCollection.get_game(self.service.id, game.appid)
if self.service:
db_game = self.service.get_service_db_game(game)
else:
db_game = games_db.get_game_by_field(game.id, "id")
if not self.is_game_displayed(game) and "id" in db_game:
self.game_store.remove_game(db_game["id"])
return True
if db_game and not self.is_game_displayed(game) and "id" in db_game:
self.game_store.remove_game(db_game["id"])
return True
if db_game:
updated = self.game_store.update(db_game)
if not updated:
@ -1079,7 +1077,7 @@ class LutrisWindow(Gtk.ApplicationWindow,
self.emit("view-updated")
return True
def on_game_activated(self, view, game_id):
def on_game_activated(self, _view, game_id):
"""Handles view activations (double click, enter press)"""
if self.service:
logger.debug("Looking up %s game %s", self.service.id, game_id)

View file

@ -116,7 +116,7 @@ class GameStore(GObject.Object):
self.store.remove(row.iter)
def update(self, db_game):
"""Update game informations
"""Update game information
Return whether a row was updated; False if the game was not already
present.
"""

View file

@ -354,6 +354,11 @@ class BaseService(GObject.Object):
to extract its platform, or returns an empty list if this is not available."""
return []
def get_service_db_game(self, game: Game):
"""Returns the row dictionary for the service-game corresponding to the
PGA game given, if any, or None."""
return ServiceGameCollection.get_game(self.id, game.appid)
class OnlineService(BaseService):
"""Base class for online gaming services"""

View file

@ -10,6 +10,7 @@ from lutris import settings
from lutris.api import get_api_games, get_game_installers, read_api_key
from lutris.database.games import get_games
from lutris.database.services import ServiceGameCollection
from lutris.game import Game
from lutris.gui import dialogs
from lutris.gui.views.media_loader import download_media
from lutris.services.base import LutrisBanner, LutrisCoverart, LutrisCoverartMedium, LutrisIcon, OnlineService
@ -152,6 +153,9 @@ class LutrisService(OnlineService):
return [p.get("name") for p in platforms]
return []
def get_service_db_game(self, game: Game):
return ServiceGameCollection.get_game(self.id, game.slug)
def download_lutris_media(slug):
"""Download all media types for a single lutris game"""