diff --git a/openpype/tools/ayon_utils/widgets/utils.py b/openpype/tools/ayon_utils/widgets/utils.py index 2817b5efc0..5165b3a262 100644 --- a/openpype/tools/ayon_utils/widgets/utils.py +++ b/openpype/tools/ayon_utils/widgets/utils.py @@ -15,6 +15,7 @@ class RefreshThread(QtCore.QThread): self._callback = partial(func, *args, **kwargs) self._exception = None self._result = None + self.finished.connect(self._on_finish_callback) @property def id(self): @@ -29,11 +30,19 @@ class RefreshThread(QtCore.QThread): self._result = self._callback() except Exception as exc: self._exception = exc - self.refresh_finished.emit(self.id) def get_result(self): return self._result + def _on_finish_callback(self): + """Trigger custom signal with thread id. + + Listening for 'finished' signal we make sure that execution of thread + finished and QThread object can be safely deleted. + """ + + self.refresh_finished.emit(self.id) + class _IconsCache: """Cache for icons."""