sip: switch to new PyQt5 api import, with fallback to the old implementation if not found.

Also calls to setapi are not needed anymore, so use them only with the old implementation.

See: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=966045
for reference
This commit is contained in:
Gianfranco Costamagna 2020-07-27 14:38:21 +02:00
parent abfac52c34
commit 32a79f18a4
8 changed files with 35 additions and 11 deletions

View File

@ -16,6 +16,9 @@ getMillis = lambda: int(round(time.time() * 1000))
if hasattr(QtCore, 'PYQT_VERSION'):
try:
try:
from PyQt5 import sip
except ImportError:
import sip
HAVE_SIP = True
except ImportError:

View File

@ -320,6 +320,9 @@ if QT_LIB in [PYSIDE, PYSIDE2]:
if QT_LIB in [PYQT4, PYQT5]:
QtVersion = QtCore.QT_VERSION_STR
try:
from PyQt5 import sip
except ImportError:
import sip
def isQObjectAlive(obj):
return not sip.isdeleted(obj)

View File

@ -1083,6 +1083,9 @@ def listQThreads():
"""Prints Thread IDs (Qt's, not OS's) for all QThreads."""
thr = findObj('[Tt]hread')
thr = [t for t in thr if isinstance(t, QtCore.QThread)]
try:
from PyQt5 import sip
except ImportError:
import sip
for t in thr:
print("--> ", t)

View File

@ -1,4 +1,7 @@
# -*- coding: utf-8 -*-
#try:
# from PyQt5 import sip
#except ImportError:
# import sip
# sip.setapi('QString', 1)

View File

@ -1,5 +1,8 @@
from ..Qt import QtGui, QtCore, QT_LIB
if QT_LIB in ['PyQt4', 'PyQt5']:
try:
from PyQt5 import sip
except ImportError:
import sip
from .GraphicsItem import GraphicsItem

View File

@ -2,6 +2,9 @@ from ..Qt import QtGui, QtCore, QT_LIB
import weakref
from .GraphicsObject import GraphicsObject
if QT_LIB in ['PyQt4', 'PyQt5']:
try:
from PyQt5 import sip
except ImportError:
import sip
__all__ = ['UIGraphicsItem']

View File

@ -25,6 +25,9 @@ if __name__ == '__main__':
pyqtapis = opts.pop('pyqtapis', None)
if pyqtapis is not None:
try:
from PyQt5 import sip
except ImportError:
import sip
for k,v in pyqtapis.items():
sip.setapi(k, v)

View File

@ -1,5 +1,8 @@
from ..Qt import QtGui, QtCore, QT_LIB
if QT_LIB in ['PyQt4', 'PyQt5']:
try:
from PyQt5 import sip
except ImportError:
import sip
from .. import multiprocess as mp
from .GraphicsView import GraphicsView