Skip to content

The only downloader you need. 下载器的集大成者。

fix(lifecycle): 补全关闭路径,删除死参数

XiaoYouChR2bfc32220ec2
diff --git a/Ghost-Downloader-3.py b/Ghost-Downloader-3.py
index 6791bb2b..f7ef4ed3 100644
--- a/Ghost-Downloader-3.py
+++ b/Ghost-Downloader-3.py
@@ -274,7 +274,7 @@ def startApp(application, isSilent=False):
updateService.changed.connect(onUpdateChanged)
checkUpdateAtStartup(updateService)
- application.aboutToQuit.connect(lambda: stopEngine(taskService, browserService, aria2RpcServer, featureService, coroutineRunner, updateService))
+ application.aboutToQuit.connect(lambda: stopEngine(taskService, browserService, aria2RpcServer, featureService, coroutineRunner, speedMeter, updateService))
if __name__ == "__main__":
diff --git a/android/main.py b/android/main.py
index 98a0bf37..fa3ced68 100644
--- a/android/main.py
+++ b/android/main.py
@@ -150,7 +150,7 @@ def startApp(application):
updateService.changed.connect(onUpdateChanged)
checkUpdateAtStartup(updateService)
- application.aboutToQuit.connect(lambda: stopEngine(taskService, browserService, aria2RpcServer, featureService, coroutineRunner, updateService))
+ application.aboutToQuit.connect(lambda: stopEngine(taskService, browserService, aria2RpcServer, featureService, coroutineRunner, speedMeter, updateService))
if __name__ == "__main__":
diff --git a/android/preview.py b/android/preview.py
index 1d7457f7..93e54df5 100644
--- a/android/preview.py
+++ b/android/preview.py
@@ -43,5 +43,5 @@ if __name__ == "__main__":
setupTouchScrolling(window)
startEngine(taskService, speedMeter, featureService, coroutineRunner)
- app.aboutToQuit.connect(lambda: stopEngine(taskService, browserService, aria2RpcServer, featureService, coroutineRunner))
+ app.aboutToQuit.connect(lambda: stopEngine(taskService, browserService, aria2RpcServer, featureService, coroutineRunner, speedMeter))
sys.exit(app.exec())
diff --git a/app/services/aria2_rpc.py b/app/services/aria2_rpc.py
index 98f5449e..1f2b5659 100644
--- a/app/services/aria2_rpc.py
+++ b/app/services/aria2_rpc.py
@@ -25,7 +25,7 @@ JSONRPC_METHOD_NOT_FOUND = -32601
class Aria2RpcServer:
taskDraftRequested = Signal(list)
- def __init__(self, coroutineRunner, parse, addTask, parent=None) -> None:
+ def __init__(self, coroutineRunner, parse, addTask) -> None:
self._coroutineRunner = coroutineRunner
self._parse = parse
self._addTask = addTask
diff --git a/app/services/runtime_status.py b/app/services/runtime_status.py
index edd11ea6..1644f8bd 100644
--- a/app/services/runtime_status.py
+++ b/app/services/runtime_status.py
@@ -29,7 +29,7 @@ class RuntimeStatus:
class RuntimeStatusService:
statusChanged = Signal(object)
- def __init__(self, coroutineRunner, parent=None):
+ def __init__(self, coroutineRunner):
self._coroutineRunner = coroutineRunner
self._statuses: dict[str, RuntimeStatus] = {}
self._workIds: dict[str, str] = {}
diff --git a/app/services/task_draft.py b/app/services/task_draft.py
index 1783cbfd..2238f23d 100644
--- a/app/services/task_draft.py
+++ b/app/services/task_draft.py
@@ -31,7 +31,7 @@ class TaskDraft:
itemsCleared = Signal()
taskConfirmed = Signal(object, bool)
- def __init__(self, coroutineRunner, featureService, parent=None):
+ def __init__(self, coroutineRunner, featureService):
self._coroutineRunner = coroutineRunner
self._featureService = featureService
self._items: list[DraftItem] = []
diff --git a/app/services/update_service.py b/app/services/update_service.py
index 3ed12ba6..3e748057 100644
--- a/app/services/update_service.py
+++ b/app/services/update_service.py
@@ -115,7 +115,7 @@ class UpdateInfo:
class UpdateService:
changed = Signal(object)
- def __init__(self, coroutineRunner: CoroutineRunner, parent=None):
+ def __init__(self, coroutineRunner: CoroutineRunner):
self._coroutineRunner = coroutineRunner
self._infos: dict[str, UpdateInfo] = {}
self._versionsData: dict = {}
diff --git a/app/startup.py b/app/startup.py
index fcf0b29a..27c4dd50 100644
--- a/app/startup.py
+++ b/app/startup.py
@@ -91,9 +91,10 @@ def checkUpdateAtStartup(updateService):
updateService.check()
-def stopEngine(taskService, browserService, aria2RpcServer, featureService, coroutineRunner, updateService=None):
+def stopEngine(taskService, browserService, aria2RpcServer, featureService, coroutineRunner, speedMeter, updateService=None):
taskService.stop()
taskService.flush()
+ speedMeter.stop()
browserService.stop()
aria2RpcServer.stop()
featureService.deactivate(coroutineRunner)
diff --git a/app/view/mobile/window.py b/app/view/mobile/window.py
index ba14e4dd..d5166166 100644
--- a/app/view/mobile/window.py
+++ b/app/view/mobile/window.py
@@ -51,7 +51,7 @@ class MobileMainWindow(QWidget):
self.addButton = PrimaryToolButton(FluentIcon.ADD, self)
self.vBoxLayout = QVBoxLayout(self)
- self._draft = TaskDraft(coroutineRunner, featureService, parent=self)
+ self._draft = TaskDraft(coroutineRunner, featureService)
self._draftDialog = TaskDraftDialog(self._draft, featureService, categoryService, parent=self)
self._initWidget()
diff --git a/app/view/windows/main_window.py b/app/view/windows/main_window.py
index 117a43d4..931aea7c 100644
--- a/app/view/windows/main_window.py
+++ b/app/view/windows/main_window.py
@@ -99,7 +99,7 @@ class MainWindow(MSFluentWindow):
self._pages: dict[str, QWidget] = {}
self._progressToast = None
- self._draft = TaskDraft(self._coroutineRunner, self._featureService, parent=self)
+ self._draft = TaskDraft(self._coroutineRunner, self._featureService)
self.searchEdit = SearchLineEdit(self.titleBar)
self._initWidget()