diff --git a/Orange/widgets/unsupervised/owlouvainclustering.py b/Orange/widgets/unsupervised/owlouvainclustering.py index d8b9268a2d1..3d34d8d9b7d 100644 --- a/Orange/widgets/unsupervised/owlouvainclustering.py +++ b/Orange/widgets/unsupervised/owlouvainclustering.py @@ -210,7 +210,7 @@ def commit(self): louvain = Louvain() self.preprocessed_data = louvain.preprocess(self.data) - state = TaskState() + state = TaskState(self) # Prepare/assemble the task(s) to run; reuse partial results if self.apply_pca: @@ -269,6 +269,8 @@ def __on_done(self, future): assert self.__task is not None assert self.__task.future is future assert self.__task.watcher.future() is future + self.__task.deleteLater() + self.__task.setParent(None) self.__task = None self.__set_state_ready() try: @@ -315,11 +317,12 @@ def __cancel_task(self, wait=True): state.status_changed.disconnect(self.setStatusMessage) state.progress_changed.disconnect(self.progressBarSet) state.watcher.done.disconnect(self.__on_done) - if state.parent() is self: - state.setParent(None) - if wait and state.future is not None: futures.wait([state.future]) + state.deleteLater() + elif state.future is not None: + w = FutureWatcher(state.future, parent=state) + w.done.connect(state.deleteLater) def __set_results(self, results): # type: ('Results') -> None