Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PR: Use currentThreadId to identify thread for PyQt bindings #224

Merged
merged 2 commits into from
Dec 21, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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:
dalthviz marked this conversation as resolved.
Show resolved Hide resolved
cache[tid] = {}
def clear_cache(): cache.pop(tid)
Expand Down