mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +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.
57 lines
1.7 KiB
Python
57 lines
1.7 KiB
Python
from __future__ import annotations
|
|
|
|
from PySide2.QtCore import Property, QObject, Signal
|
|
|
|
from game.server.leaflet import LeafletPoly, ShapelyUtil
|
|
from game.theater import ConflictTheater
|
|
from game.threatzones import ThreatZones
|
|
|
|
|
|
class ThreatZonesJs(QObject):
|
|
fullChanged = Signal()
|
|
aircraftChanged = Signal()
|
|
airDefensesChanged = Signal()
|
|
radarSamsChanged = Signal()
|
|
|
|
def __init__(
|
|
self,
|
|
full: list[LeafletPoly],
|
|
aircraft: list[LeafletPoly],
|
|
air_defenses: list[LeafletPoly],
|
|
radar_sams: list[LeafletPoly],
|
|
) -> None:
|
|
super().__init__()
|
|
self._full = full
|
|
self._aircraft = aircraft
|
|
self._air_defenses = air_defenses
|
|
self._radar_sams = radar_sams
|
|
|
|
@Property(list, notify=fullChanged)
|
|
def full(self) -> list[LeafletPoly]:
|
|
return self._full
|
|
|
|
@Property(list, notify=aircraftChanged)
|
|
def aircraft(self) -> list[LeafletPoly]:
|
|
return self._aircraft
|
|
|
|
@Property(list, notify=airDefensesChanged)
|
|
def airDefenses(self) -> list[LeafletPoly]:
|
|
return self._air_defenses
|
|
|
|
@Property(list, notify=radarSamsChanged)
|
|
def radarSams(self) -> list[LeafletPoly]:
|
|
return self._radar_sams
|
|
|
|
@classmethod
|
|
def from_zones(cls, zones: ThreatZones, theater: ConflictTheater) -> ThreatZonesJs:
|
|
return ThreatZonesJs(
|
|
ShapelyUtil.polys_to_leaflet(zones.all, theater),
|
|
ShapelyUtil.polys_to_leaflet(zones.airbases, theater),
|
|
ShapelyUtil.polys_to_leaflet(zones.air_defenses, theater),
|
|
ShapelyUtil.polys_to_leaflet(zones.radar_sam_threats, theater),
|
|
)
|
|
|
|
@classmethod
|
|
def empty(cls) -> ThreatZonesJs:
|
|
return ThreatZonesJs([], [], [], [])
|