Add FastAPI interface between the game and map.

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.
This commit is contained in:
Dan Albert
2022-02-13 14:22:05 -08:00
parent 1df31b2496
commit 350f08be2f
33 changed files with 419 additions and 330 deletions

View File

@@ -9,7 +9,7 @@ from typing import Optional
from PySide2 import QtWidgets
from PySide2.QtCore import Qt
from PySide2.QtGui import QPixmap
from PySide2.QtWidgets import QApplication, QSplashScreen, QCheckBox
from PySide2.QtWidgets import QApplication, QCheckBox, QSplashScreen
from dcs.payloads import PayloadDirectories
from game import Game, VERSION, persistency
@@ -18,6 +18,7 @@ from game.data.weapons import Pylon, Weapon, WeaponGroup
from game.db import FACTIONS
from game.dcs.aircrafttype import AircraftType
from game.profiling import logged_duration
from game.server import GameContext, Server
from game.settings import Settings
from game.theater.start_generator import GameGenerator, GeneratorSettings, ModSettings
from qt_ui import (
@@ -135,6 +136,7 @@ def run_ui(game: Optional[Game]) -> None:
# Apply CSS (need works)
GameUpdateSignal()
GameUpdateSignal.get_instance().game_loaded.connect(GameContext.set)
# Start window
window = QLiberationWindow(game)
@@ -333,7 +335,8 @@ def main():
lint_weapon_data_for_aircraft(AircraftType.named(args.aircraft))
return
run_ui(game)
with Server().run_in_thread():
run_ui(game)
if __name__ == "__main__":