mirror of
https://github.com/ankitects/anki.git
synced 2025-09-23 16:26:40 -04:00
Ignore TaskManager's on_done callback if collection unloaded (#4076)
* Ignore TaskManager's on_done callback if collection unloaded * Check col.db
This commit is contained in:
parent
6004616672
commit
ccc42227d8
1 changed files with 8 additions and 1 deletions
|
@ -84,8 +84,15 @@ class TaskManager(QObject):
|
||||||
fut = executor.submit(task, **args)
|
fut = executor.submit(task, **args)
|
||||||
|
|
||||||
if on_done is not None:
|
if on_done is not None:
|
||||||
|
|
||||||
|
def wrapped_done(future: Future) -> None:
|
||||||
|
if uses_collection and not (self.mw.col and self.mw.col.db):
|
||||||
|
print(f"Ignored on_done as collection unloaded: {repr(on_done)}")
|
||||||
|
return
|
||||||
|
on_done(future)
|
||||||
|
|
||||||
fut.add_done_callback(
|
fut.add_done_callback(
|
||||||
lambda future: self.run_on_main(lambda: on_done(future))
|
lambda future: self.run_on_main(lambda: wrapped_done(future))
|
||||||
)
|
)
|
||||||
|
|
||||||
return fut
|
return fut
|
||||||
|
|
Loading…
Reference in a new issue