mirror of
https://github.com/ankitects/anki.git
synced 2025-09-19 06:22:22 -04:00
fix progress manager window race condition (#3029)
The progress manager was indicating windows were in a clean state before actually ensuring they were in a clean state. The update to mark things as clean now occurs after cleanup has occurred.
This commit is contained in:
parent
103ea6ded0
commit
d4a52b7548
1 changed files with 6 additions and 3 deletions
|
@ -223,9 +223,11 @@ class ProgressManager:
|
||||||
self._win.form.progressBar.setValue(self._counter)
|
self._win.form.progressBar.setValue(self._counter)
|
||||||
|
|
||||||
def finish(self) -> None:
|
def finish(self) -> None:
|
||||||
self._levels -= 1
|
# we must latch the levels update and perform it after cleanup has occured or we expose ourselves to a race
|
||||||
self._levels = max(0, self._levels)
|
# condition where a second progress could see levels == 0 and wrongly assume everything is in a clean state
|
||||||
if self._levels == 0:
|
next_levels = self._levels - 1
|
||||||
|
next_levels = max(0, next_levels)
|
||||||
|
if next_levels == 0:
|
||||||
if self._win:
|
if self._win:
|
||||||
self._closeWin()
|
self._closeWin()
|
||||||
if self._busy_cursor_timer:
|
if self._busy_cursor_timer:
|
||||||
|
@ -239,6 +241,7 @@ class ProgressManager:
|
||||||
self._backend_timer.stop()
|
self._backend_timer.stop()
|
||||||
self._backend_timer.deleteLater()
|
self._backend_timer.deleteLater()
|
||||||
self._backend_timer = None
|
self._backend_timer = None
|
||||||
|
self._levels = next_levels
|
||||||
|
|
||||||
def clear(self) -> None:
|
def clear(self) -> None:
|
||||||
"Restore the interface after an error."
|
"Restore the interface after an error."
|
||||||
|
|
Loading…
Reference in a new issue