From 8117d33220f1377128a21937920e27dc13efcb9b Mon Sep 17 00:00:00 2001 From: Pierre Raybaut Date: Sat, 6 Jul 2024 14:08:10 +0200 Subject: [PATCH] Fixed random crashes (segfaults) on Linux related to Qt objects stored in cache data --- CHANGELOG.md | 9 +++++++++ qwt/__init__.py | 2 +- qwt/symbol.py | 4 ++-- qwt/text.py | 7 ++++--- 4 files changed, 16 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c3ab064..f32e145 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,14 @@ # PythonQwt Releases +## Version 0.12.6 + +- Fixed random crashes (segfaults) on Linux related to Qt objects stored in cache data + structures (`QwtText` and `QwtSymbol`) + +- Test suite can simply be run with `pytest` and specific configuration (`conftest.py`) + will be taken into account (previously, the test suite has to be run with + `pytest qwt` in order to be successfully configured) + ## Version 0.12.5 - Add support for NumPy 2.0: diff --git a/qwt/__init__.py b/qwt/__init__.py index 6ec588b..be5b4a1 100644 --- a/qwt/__init__.py +++ b/qwt/__init__.py @@ -55,7 +55,7 @@ from qwt.text import QwtText # noqa: F401 from qwt.toqimage import array_to_qimage as toQImage # noqa: F401 -__version__ = "0.12.5" +__version__ = "0.12.6" QWT_VERSION_STR = "6.1.5" diff --git a/qwt/symbol.py b/qwt/symbol.py index a1cbb8e..0f9bbb8 100644 --- a/qwt/symbol.py +++ b/qwt/symbol.py @@ -341,7 +341,7 @@ def __init__(self, st, br, pn, sz): self.brush = br self.pen = pn self.isPinPointEnabled = False - self.pinPoint = QPointF() + self.pinPoint = None class Path(object): def __init__(self): @@ -1235,7 +1235,7 @@ def invalidateCache(self): :py:meth:`setCachePolicy()`, :py:meth:`drawSymbols()` """ if self.__data.cache.pixmap is not None: - self.__data.cache.pixmap = QPixmap() + self.__data.cache.pixmap = None def setStyle(self, style): """ diff --git a/qwt/text.py b/qwt/text.py index 7f37e50..65b310e 100644 --- a/qwt/text.py +++ b/qwt/text.py @@ -474,11 +474,11 @@ def __init__(self): class QwtText_LayoutCache(object): def __init__(self): - self.textSize = QSizeF() + self.textSize = None self.font = None def invalidate(self): - self.textSize = QSizeF() + self.textSize = None class QwtText(object): @@ -987,7 +987,8 @@ def textSize(self, defaultFont): """ font = QFont(self.usedFont(defaultFont)) if ( - not self.__layoutCache.textSize.isValid() + self.__layoutCache.textSize is None + or not self.__layoutCache.textSize.isValid() or self.__layoutCache.font is not font ): self.__layoutCache.textSize = self.__data.textEngine.textSize(