mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-07 10:14:46 -04:00
IGN:Fix reading of epub metadata in non GUI threads
This commit is contained in:
parent
939963d366
commit
c50e47fdd8
@ -158,6 +158,8 @@ class CoverRenderer(QObject):
|
||||
|
||||
|
||||
def get_cover(opf, opf_path, stream):
|
||||
from calibre.gui2 import is_ok_to_use_qt
|
||||
if not is_ok_to_use_qt(): return None
|
||||
spine = list(opf.spine_items())
|
||||
if not spine:
|
||||
return
|
||||
|
@ -3,7 +3,7 @@ __copyright__ = '2008, Kovid Goyal <kovid at kovidgoyal.net>'
|
||||
""" The GUI """
|
||||
import os
|
||||
from PyQt4.QtCore import QVariant, QFileInfo, QObject, SIGNAL, QBuffer, Qt, QSize, \
|
||||
QByteArray, QUrl, QTranslator, QCoreApplication
|
||||
QByteArray, QUrl, QTranslator, QCoreApplication, QThread
|
||||
from PyQt4.QtGui import QFileDialog, QMessageBox, QPixmap, QFileIconProvider, \
|
||||
QIcon, QTableView, QApplication, QDialog
|
||||
|
||||
@ -457,11 +457,14 @@ try:
|
||||
except:
|
||||
SingleApplication = None
|
||||
|
||||
gui_thread = None
|
||||
|
||||
class Application(QApplication):
|
||||
|
||||
def __init__(self, args):
|
||||
qargs = [i.encode('utf-8') if isinstance(i, unicode) else i for i in args]
|
||||
QApplication.__init__(self, qargs)
|
||||
gui_thread = QThread.currentThread()
|
||||
self.translator = QTranslator(self)
|
||||
lang = get_lang()
|
||||
if lang:
|
||||
@ -470,3 +473,11 @@ class Application(QApplication):
|
||||
self.translator.loadFromData(data)
|
||||
self.installTranslator(self.translator)
|
||||
|
||||
def is_ok_to_use_qt():
|
||||
global gui_thread
|
||||
if QApplication.instance() is None:
|
||||
QApplication([])
|
||||
if gui_thread is None:
|
||||
gui_thread = QThread.currentThread()
|
||||
return gui_thread is QThread.currentThread()
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user