Skip to content

Commit

Permalink
Merge pull request #224 from dalthviz/fixes_issue_223
Browse files Browse the repository at this point in the history
PR: Use currentThreadId to identify thread for PyQt bindings
  • Loading branch information
ccordoba12 authored Dec 21, 2022
2 parents 136802a + 6667f4b commit 09fc3e7
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions qtawesome/iconic_font.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
import warnings

# Third party imports
from qtpy.QtCore import (QByteArray, QObject, QPoint, QRect, Qt,
from qtpy import PYSIDE2, PYSIDE6
from qtpy.QtCore import (QObject, QPoint, QRect, Qt,
QSizeF, QRectF, QPointF, QThread)
from qtpy.QtGui import (QColor, QFont, QFontDatabase, QIcon, QIconEngine,
QPainter, QPixmap, QTransform, QPalette, QRawFont,
Expand Down Expand Up @@ -531,7 +532,12 @@ def rawfont(self, prefix, size, hintingPreference=QFont.PreferDefaultHinting):
# (either using a constructor, or by calling loadFromData() or loadFromFile()).
# The QRawFont cannot be moved to a different thread,
# but will have to be recreated in the thread in question.
tid = str(QThread.currentThread())
if PYSIDE2 or PYSIDE6:
# Needed since PySide* bindings don't expose QThread.currentThreadId
tid = str(QThread.currentThread())
else:
tid = int(QThread.currentThreadId())

if tid not in cache:
cache[tid] = {}
def clear_cache(): cache.pop(tid)
Expand Down

0 comments on commit 09fc3e7

Please sign in to comment.