Skip to content

Commit

Permalink
Fixed random crashes (segfaults) on Linux related to Qt objects store…
Browse files Browse the repository at this point in the history
…d in cache data
  • Loading branch information
PierreRaybaut committed Jul 6, 2024
1 parent 9605407 commit 8117d33
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 6 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
2 changes: 1 addition & 1 deletion qwt/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"


Expand Down
4 changes: 2 additions & 2 deletions qwt/symbol.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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):
"""
Expand Down
7 changes: 4 additions & 3 deletions qwt/text.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit 8117d33

Please sign in to comment.