Fix bug in loadProfile method (#229)

Bug: if sync is enabled for profile, then we have alot of recursive
calls to loadProfile method because main window is still active until
sync is ended. And this freezes Anki app.
This commit is contained in:
Kirill Salnikov 2021-02-08 04:40:44 +03:00 committed by GitHub
parent 6487abe206
commit 4d2ab991c2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -304,7 +304,17 @@ class AnkiConnect:
cur_profile = self.window().pm.name
if cur_profile != name:
self.window().unloadProfileAndShowProfileManager()
def waiter():
# This function waits until main window is closed
# It's needed cause sync can take quite some time
# And if we call loadProfile until sync is ended things will go wrong
if self.window().isVisible():
QTimer.singleShot(1000, waiter)
else:
self.loadProfile(name)
waiter()
else:
self.window().pm.load(name)
self.window().loadProfile()