diff --git a/src/tagstudio/qt/utils/custom_runnable.py b/src/tagstudio/qt/utils/custom_runnable.py index 06932bc7..9792fdf1 100644 --- a/src/tagstudio/qt/utils/custom_runnable.py +++ b/src/tagstudio/qt/utils/custom_runnable.py @@ -2,17 +2,23 @@ # SPDX-License-Identifier: GPL-3.0-only +from collections.abc import Callable +from typing import override + from PySide6.QtCore import QObject, QRunnable, Signal class CustomRunnable(QRunnable, QObject): # pyright: ignore[reportUnsafeMultipleInheritance] done = Signal() - def __init__(self, function) -> None: + def __init__(self, function: Callable[..., None]) -> None: QRunnable.__init__(self) QObject.__init__(self) + self.setAutoDelete(False) self.function = function + @override def run(self): self.function() self.done.emit() + self.deleteLater()