From 12bdb21af11af289ce1d77c6753c12389619c7ef Mon Sep 17 00:00:00 2001 From: Ales Erjavec Date: Fri, 25 May 2018 13:19:58 +0200 Subject: [PATCH] VizRank: Fix race condition in `toggle` There was a race condition in the `toggle` method where VizRank could be left without a running worker thread. This could happen between setting keep_running from False to True and subsequent call to QThread.start. The worker could read keep_running as False right before that and not yet exit before the call to start. Then start would be a noop and the thread would stop right after. Fix by explicitly joining on the thread on 'pause' as a synchronization point. --- Orange/widgets/visualize/utils/__init__.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Orange/widgets/visualize/utils/__init__.py b/Orange/widgets/visualize/utils/__init__.py index f4c714d4f93..e39d95f2923 100644 --- a/Orange/widgets/visualize/utils/__init__.py +++ b/Orange/widgets/visualize/utils/__init__.py @@ -352,6 +352,9 @@ def toggle(self): else: self.button.setText("Continue") self._thread.quit() + # Need to sync state (the worker must read the keep_running + # state and stop) for reliable restart. + self._thread.wait() def before_running(self): """Code that is run before running vizrank in its own thread"""