QueryOp() was attempting to open progress window on background thread

This commit is contained in:
Damien Elmes 2021-12-04 08:37:42 +10:00
parent 936323e430
commit 42455eca64

View file

@ -176,7 +176,11 @@ class QueryOp(Generic[T]):
self._failure = failure self._failure = failure
return self return self
def with_progress(self, label: str | None = None) -> QueryOp[T]: def with_progress(
self,
label: str | None = None,
) -> QueryOp[T]:
"If label not provided, will default to 'Processing...'"
self._progress = label or True self._progress = label or True
return self return self
@ -195,7 +199,12 @@ class QueryOp(Generic[T]):
label = self._progress label = self._progress
else: else:
label = None label = None
def start_progress() -> None:
assert mw
mw.progress.start(label=label) mw.progress.start(label=label)
mw.taskman.run_on_main(start_progress)
return self._op(mw.col) return self._op(mw.col)
def wrapped_done(future: Future) -> None: def wrapped_done(future: Future) -> None: