From 96090740c475b10bc66e025c1c96ec0c3742d5f4 Mon Sep 17 00:00:00 2001 From: gounux Date: Sun, 21 Jul 2024 10:42:38 +0200 Subject: [PATCH] set taskmanager in widget initialization --- qtribu/gui/wdg_qchat.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/qtribu/gui/wdg_qchat.py b/qtribu/gui/wdg_qchat.py index cff94cf3..5ae84923 100644 --- a/qtribu/gui/wdg_qchat.py +++ b/qtribu/gui/wdg_qchat.py @@ -3,7 +3,7 @@ from datetime import datetime from functools import partial from pathlib import Path -from typing import Any +from typing import Any, Optional # PyQGIS # @@ -31,7 +31,7 @@ class QChatWidget(QgsDockWidget): connected: bool = False - current_room: str = None + current_room: Optional[str] = None settings: PlgSettingsStructure qchat_client = QChatApiClient @@ -44,6 +44,7 @@ def __init__(self, iface: QgisInterface, parent: QWidget = None): """ super().__init__(parent) self.iface = iface + self.task_manager = QgsApplication.taskManager() self.log = PlgLogger().log self.plg_settings = PlgOptionsManager() uic.loadUi(Path(__file__).parent / f"{Path(__file__).stem}.ui", self) @@ -267,7 +268,7 @@ def on_ws_message_received(self, message: str) -> None: message = json.loads(message) if message["message"] == CHEATCODE_DIZZY: task = DizzyTask("Cheatcode activation", self.iface) - QgsApplication.taskManager().addTask(task) + self.task_manager.addTask(task) return self.tw_chat.insertTopLevelItem( 0, self.add_message_to_treeview(self.current_room, message)