mirror of
https://github.com/ankitects/anki.git
synced 2025-09-25 09:16:38 -04:00
try to work around the qbytearray issue
https://anki.tenderapp.com/discussions/ankidesktop/3369-bug-report-for-restoring-from-backup
This commit is contained in:
parent
da1672d42f
commit
9cb1d19dc2
1 changed files with 19 additions and 5 deletions
24
aqt/main.py
24
aqt/main.py
|
@ -2,20 +2,29 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||
|
||||
import os, sys, re, traceback, signal
|
||||
import os
|
||||
import sys
|
||||
import re
|
||||
import traceback
|
||||
import signal
|
||||
import zipfile
|
||||
|
||||
from send2trash import send2trash
|
||||
from aqt.qt import *
|
||||
|
||||
from anki import Collection
|
||||
from anki.utils import isWin, isMac, intTime, splitFields, ids2str
|
||||
from anki.hooks import runHook, addHook
|
||||
|
||||
import aqt, aqt.progress, aqt.webview, aqt.toolbar, aqt.stats
|
||||
from anki.hooks import runHook, addHook
|
||||
import aqt
|
||||
import aqt.progress
|
||||
import aqt.webview
|
||||
import aqt.toolbar
|
||||
import aqt.stats
|
||||
from aqt.utils import restoreGeom, showInfo, showWarning,\
|
||||
restoreState, getOnlyText, askUser, applyStyles, showText, tooltip, \
|
||||
openHelp, openLink, checkInvalidFilename
|
||||
|
||||
|
||||
class AnkiQt(QMainWindow):
|
||||
def __init__(self, app, profileManager, args):
|
||||
QMainWindow.__init__(self)
|
||||
|
@ -159,7 +168,6 @@ class AnkiQt(QMainWindow):
|
|||
return True
|
||||
|
||||
def profileNameOk(self, str):
|
||||
from anki.utils import invalidFilename, invalidFilenameChars
|
||||
return not checkInvalidFilename(str)
|
||||
|
||||
def onAddProfile(self):
|
||||
|
@ -1051,6 +1059,8 @@ will be lost. Continue?"""))
|
|||
elif isWin:
|
||||
# make sure ctypes is bundled
|
||||
from ctypes import windll, wintypes
|
||||
_dummy = windll
|
||||
_dummy = wintypes
|
||||
|
||||
def maybeHideAccelerators(self, tgt=None):
|
||||
if not self.hideMenuAccels:
|
||||
|
@ -1076,6 +1086,10 @@ will be lost. Continue?"""))
|
|||
self.connect(self.app, SIGNAL("appMsg"), self.onAppMsg)
|
||||
|
||||
def onAppMsg(self, buf):
|
||||
if not isinstance(buf, unicode):
|
||||
# even though we're sending this as unicode up above,
|
||||
# a bug report still came in that we were receiving a qbytearray
|
||||
buf = unicode(buf, "utf8", "ignore")
|
||||
if self.state == "startup":
|
||||
# try again in a second
|
||||
return self.progress.timer(1000, lambda: self.onAppMsg(buf), False)
|
||||
|
|
Loading…
Reference in a new issue