mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Ensure that the imageformat Qt plugins are loaded even when no QApplication is created
This commit is contained in:
parent
48f4670ed5
commit
a182438cba
@ -6,8 +6,5 @@ env:
|
||||
|
||||
before_install:
|
||||
- curl https://download.calibre-ebook.com/travis/sw-linux.tar.xz | tar xJ -C $HOME
|
||||
- $QMAKE -query
|
||||
- ldd $SW/qt/plugins/imageformats/libqjpeg.so
|
||||
- python -c "import os, sys; os.environ['QT_DEBUG_PLUGINS']='1'; from PyQt5.Qt import *; print QLibraryInfo.location(QLibraryInfo.PluginsPath); fmts = map(str, QImageReader.supportedImageFormats()); print fmts; sys.exit('jpg' not in fmts)"
|
||||
- python setup.py bootstrap --ephemeral
|
||||
script: python setup.py test
|
||||
|
@ -4,17 +4,29 @@
|
||||
|
||||
from __future__ import (unicode_literals, division, absolute_import,
|
||||
print_function)
|
||||
from future_builtins import map
|
||||
import os, subprocess, errno, shutil, tempfile, sys
|
||||
from io import BytesIO
|
||||
from threading import Thread
|
||||
|
||||
from PyQt5.Qt import QImage, QByteArray, QBuffer, Qt, QImageReader, QColor, QImageWriter, QTransform
|
||||
from PyQt5.Qt import QImage, QByteArray, QBuffer, Qt, QImageReader, QColor, QImageWriter, QTransform, QCoreApplication, QProcessEnvironment
|
||||
|
||||
from calibre import fit_image, force_unicode
|
||||
from calibre.constants import iswindows, plugins, get_version
|
||||
from calibre.utils.config_base import tweaks
|
||||
from calibre.utils.filenames import atomic_rename
|
||||
|
||||
# Ensure that Qt can load the imageformat plugins
|
||||
|
||||
if QCoreApplication.instance() is None:
|
||||
# Normally constructing a QCoreApplication takes care of this, but if we
|
||||
# are being used without a QCoreApplication, then we have to do it manually
|
||||
if len(set(b'jpeg gif png'.split(b' ')).intersection(set(map(bytes, QImageReader.supportedImageFormats())))) != 3:
|
||||
qpp = QProcessEnvironment.systemEnvironment().value('QT_PLUGIN_PATH')
|
||||
if qpp:
|
||||
for path in qpp.split(os.pathsep):
|
||||
QCoreApplication.addLibraryPath(path)
|
||||
|
||||
# Utilities {{{
|
||||
imageops, imageops_err = plugins['imageops']
|
||||
if imageops is None:
|
||||
|
Loading…
x
Reference in New Issue
Block a user