chore: raise error on Nonetype model

This commit is contained in:
aclist 2026-05-14 16:44:37 +09:00
parent 88c4758c6b
commit aa6b94905a
2 changed files with 4 additions and 0 deletions

View File

@ -70,6 +70,8 @@ class ModTreeView(ModsMixin, ContextMixin, TreeView): # type: ignore
def get_selected_mod(self) -> str:
path = self.get_focused_row_path()
model = self.get_model()
if model is None:
raise AttributeError("Trying to call a method on a non-existent model")
tree_iter = model.get_iter(path)
mod = model.get(tree_iter, 2)[0]
return str(mod)

View File

@ -61,6 +61,8 @@ class ServerModTreeView(ContextMixin, TreeView): # type: ignore
def get_selected_mod(self) -> str:
path = self.get_focused_row_path()
model = self.get_model()
if model is None:
raise AttributeError("Trying to call a method on a non-existent model")
tree_iter = model.get_iter(path)
# FIXME: https://docs.gtk.org/gtk3/method.TreeModel.get.html
mod = model.get(tree_iter, 1)[0]