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:
Kieran Black 2024-02-25 00:17:04 -06:00 committed by GitHub
parent 103ea6ded0
commit d4a52b7548
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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."