mirror of
https://github.com/ankitects/anki.git
synced 2025-09-23 08:22:24 -04:00
Fix progress of chained operations (#1817)
* Fix progress of chained operations Especially aborting colpkg import. * Notify about missing progress dialog
This commit is contained in:
parent
2b739d76b2
commit
aea7eb667e
2 changed files with 9 additions and 9 deletions
|
@ -14,7 +14,7 @@ import aqt.modelchooser
|
|||
from anki.errors import Interrupted
|
||||
from anki.importing.anki2 import V2ImportIntoV1
|
||||
from anki.importing.apkg import AnkiPackageImporter
|
||||
from aqt import AnkiQt, gui_hooks
|
||||
from aqt.main import AnkiQt, gui_hooks
|
||||
from aqt.operations import QueryOp
|
||||
from aqt.qt import *
|
||||
from aqt.utils import (
|
||||
|
@ -460,12 +460,13 @@ def full_apkg_import(mw: AnkiQt, file: str) -> None:
|
|||
|
||||
|
||||
def replace_with_apkg(
|
||||
mw: aqt.AnkiQt, filename: str, callback: Callable[[bool], None]
|
||||
mw: AnkiQt, filename: str, callback: Callable[[bool], None]
|
||||
) -> None:
|
||||
"""Tries to replace the provided collection with the provided backup,
|
||||
then calls the callback. True if success.
|
||||
"""
|
||||
dialog = mw.progress.start(immediate=True)
|
||||
if not (dialog := mw.progress.start(immediate=True)):
|
||||
print("No progress dialog during import; aborting will not work")
|
||||
timer = QTimer()
|
||||
timer.setSingleShot(False)
|
||||
timer.setInterval(100)
|
||||
|
|
|
@ -217,6 +217,10 @@ class QueryOp(Generic[T]):
|
|||
|
||||
def wrapped_done(future: Future) -> None:
|
||||
assert mw
|
||||
|
||||
if self._progress:
|
||||
mw.progress.finish()
|
||||
|
||||
mw._decrease_background_ops()
|
||||
# did something go wrong?
|
||||
if exception := future.exception():
|
||||
|
@ -230,11 +234,6 @@ class QueryOp(Generic[T]):
|
|||
# BaseException like SystemExit; rethrow it
|
||||
future.result()
|
||||
|
||||
result = future.result()
|
||||
try:
|
||||
self._success(result)
|
||||
finally:
|
||||
if self._progress:
|
||||
mw.progress.finish()
|
||||
self._success(future.result())
|
||||
|
||||
mw.taskman.run_in_background(wrapped_op, wrapped_done)
|
||||
|
|
Loading…
Reference in a new issue