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.
27 lines
856 B
Python
27 lines
856 B
Python
from PySide2.QtCore import Property, QObject, Signal
|
|
|
|
from game.server.leaflet import LeafletPoly, ShapelyUtil
|
|
from game.sim.combat.aircombat import AirCombat
|
|
from game.theater import ConflictTheater
|
|
|
|
|
|
class AirCombatJs(QObject):
|
|
footprintChanged = Signal()
|
|
|
|
def __init__(self, combat: AirCombat, theater: ConflictTheater) -> None:
|
|
super().__init__()
|
|
self.combat = combat
|
|
self.theater = theater
|
|
self._footprint = self._make_footprint()
|
|
|
|
@Property(type=list, notify=footprintChanged)
|
|
def footprint(self) -> list[LeafletPoly]:
|
|
return self._footprint
|
|
|
|
def refresh(self) -> None:
|
|
self._footprint = self._make_footprint()
|
|
self.footprintChanged.emit()
|
|
|
|
def _make_footprint(self) -> list[LeafletPoly]:
|
|
return ShapelyUtil.polys_to_leaflet(self.combat.footprint, self.theater)
|