From 002f55dc04e8e07884707dd99fa8f0cb3e512521 Mon Sep 17 00:00:00 2001 From: Dan Albert Date: Sat, 17 Oct 2020 13:31:52 -0700 Subject: [PATCH] Update the map from the main window. This guarantees that we update the map *after* updating the model that the map uses to draw flight plans. Without this, after creating a new game we'd redraw the previous game's flight plans because the model hadn't been updated by the time the map was. Fixes https://github.com/Khopa/dcs_liberation/issues/212 --- qt_ui/widgets/map/QLiberationMap.py | 9 ++++----- qt_ui/windows/QLiberationWindow.py | 5 ++++- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/qt_ui/widgets/map/QLiberationMap.py b/qt_ui/widgets/map/QLiberationMap.py index 7344275f..6ccde6da 100644 --- a/qt_ui/widgets/map/QLiberationMap.py +++ b/qt_ui/widgets/map/QLiberationMap.py @@ -56,7 +56,6 @@ class QLiberationMap(QGraphicsView): self.factor = 1 self.factorized = 1 self.init_scene() - self.connectSignals() self.setGame(game_model.game) GameUpdateSignal.get_instance().flight_paths_changed.connect( @@ -109,9 +108,6 @@ class QLiberationMap(QGraphicsView): self.setFrameShape(QFrame.NoFrame) self.setDragMode(QGraphicsView.ScrollHandDrag) - def connectSignals(self): - GameUpdateSignal.get_instance().gameupdated.connect(self.setGame) - def setGame(self, game: Optional[Game]): self.game = game logging.debug("Reloading Map Canvas") @@ -263,7 +259,7 @@ class QLiberationMap(QGraphicsView): text.setDefaultTextColor(Qt.white) text.setPos(pos[0] + CONST.CP_SIZE + 1, pos[1] - CONST.CP_SIZE / 2 + 1) - def draw_flight_plans(self, scene) -> None: + def clear_flight_paths(self, scene: QGraphicsScene) -> None: for item in self.flight_path_items: try: scene.removeItem(item) @@ -271,6 +267,9 @@ class QLiberationMap(QGraphicsView): # Something may have caused those items to already be removed. pass self.flight_path_items.clear() + + def draw_flight_plans(self, scene: QGraphicsScene) -> None: + self.clear_flight_paths(scene) if DisplayOptions.flight_paths.hide: return packages = list(self.game_model.ato_model.packages) diff --git a/qt_ui/windows/QLiberationWindow.py b/qt_ui/windows/QLiberationWindow.py index db5caa10..99783d11 100644 --- a/qt_ui/windows/QLiberationWindow.py +++ b/qt_ui/windows/QLiberationWindow.py @@ -43,6 +43,7 @@ class QLiberationWindow(QMainWindow): Dialog.set_game(self.game_model) self.ato_panel = None self.info_panel = None + self.liberation_map = None self.setGame(persistency.restore_game()) self.setGeometry(300, 100, 270, 100) @@ -224,9 +225,11 @@ class QLiberationWindow(QMainWindow): if game is not None: game.on_load() self.game = game - if self.info_panel: + if self.info_panel is not None: self.info_panel.setGame(game) self.game_model.set(self.game) + if self.liberation_map is not None: + self.liberation_map.setGame(game) def showAboutDialog(self): text = "

DCS Liberation " + CONST.VERSION_STRING + "

" + \