Skip to content

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

fix(ui): 打包版删除的控件内存不释放

XiaoYouChR8bcceccf49f4
diff --git a/Ghost-Downloader-3.py b/Ghost-Downloader-3.py
index f7961046..b24b2838 100644
--- a/Ghost-Downloader-3.py
+++ b/Ghost-Downloader-3.py
@@ -20,6 +20,9 @@ sys.excepthook = _exceptionHook
def setupEnvironment():
+ from app.nuitka_patch import patchSignalWorkaround
+ patchSignalWorkaround()
+
from app.config.cfg import cfg
from app.config.constants import VERSION
from app.platform.hidden_subprocess import setupHiddenSubprocess
diff --git a/app/nuitka_patch.py b/app/nuitka_patch.py
new file mode 100644
index 00000000..f9e1e02f
--- /dev/null
+++ b/app/nuitka_patch.py
@@ -0,0 +1,14 @@
+from PySide6.QtCore import SignalInstance
+
+
+class FunctionRefs(list):
+
+ def append(self, method) -> None:
+ super().append(method.im_func)
+
+
+def patchSignalWorkaround() -> None:
+ # https://github.com/Nuitka/Nuitka/issues/4108
+ namespace = getattr(SignalInstance.connect, "__globals__", {})
+ if "_protected" in namespace:
+ namespace["_protected"] = FunctionRefs(namespace["_protected"])
diff --git a/app/view/components/dialog_animation.py b/app/view/components/dialog_animation.py
index 1418170e..137727e9 100644
--- a/app/view/components/dialog_animation.py
+++ b/app/view/components/dialog_animation.py
@@ -58,8 +58,7 @@ class AnimationLayer(QWidget):
layer._animation.stop()
self._backdrop = self._buildBackdrop()
self._animation.valueChanged.connect(self.update)
- # Nuitka 编译后会永久持有连到信号上的绑定方法,用 lambda 这一层和截图才能释放
- self._animation.stateChanged.connect(lambda state: self._onAnimationStateChanged(state))
+ self._animation.stateChanged.connect(self._onAnimationStateChanged)
# 对话框声明不透明,Qt 就不再重画底下的页面
dialog.setAttribute(Qt.WidgetAttribute.WA_OpaquePaintEvent)
# 关闭时当场截图,窗口最小化时也能关掉