mirror of
https://github.com/dcs-liberation/dcs_liberation.git
synced 2025-11-10 14:22:26 +00:00
A possible explanation for the infrequent CTDs we've been seeing since adding fast forward is that QWebChannel doesn't keep a reference to the python objects that it passes to js, so if the object is GC'd before the front end is done with it, it crashes. We don't really like QWebChannel anyway, so this begins replacing that with FastAPI.
16 lines
315 B
Python
16 lines
315 B
Python
from game import Game
|
|
|
|
|
|
class GameContext:
|
|
_game: Game | None
|
|
|
|
@classmethod
|
|
def set(cls, game: Game | None) -> None:
|
|
cls._game = game
|
|
|
|
@classmethod
|
|
def get(cls) -> Game:
|
|
if cls._game is None:
|
|
raise RuntimeError("GameContext has no Game set")
|
|
return cls._game
|