Fix CS2 loader callback
Capture the exception reference inside Tk callbacks to avoid NameError when data loading fails.
This commit is contained in:
parent
364b3e46d5
commit
856a171c66
|
|
@ -407,9 +407,9 @@ class CS2PatternTool(tk.Toplevel):
|
||||||
self.fetcher.ensure_data(force_refresh=True)
|
self.fetcher.ensure_data(force_refresh=True)
|
||||||
weapons = self.fetcher.list_weapons()
|
weapons = self.fetcher.list_weapons()
|
||||||
except Exception as exc: # noqa: BLE001
|
except Exception as exc: # noqa: BLE001
|
||||||
self.after(0, lambda: self._on_load_failed(exc))
|
self.after(0, lambda err=exc: self._on_load_failed(err))
|
||||||
return
|
return
|
||||||
self.after(0, lambda: self._on_data_ready(weapons or []))
|
self.after(0, lambda items=weapons: self._on_data_ready(items or []))
|
||||||
|
|
||||||
def _on_data_ready(self, weapons: list[str]) -> None:
|
def _on_data_ready(self, weapons: list[str]) -> None:
|
||||||
if not weapons:
|
if not weapons:
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue