Skip to content

Commit

Permalink
Fix segfault due to an internal cache mechanism
Browse files Browse the repository at this point in the history
Fix #86
  • Loading branch information
PierreRaybaut committed Jun 19, 2024
1 parent fe31462 commit 018e23d
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
# PythonQwt Releases

## Version 0.12.3

- Fixed `Fatal Python error` issue reported in the `PlotPy` project:
- See [PlotPy's Issue #11](https://github.com/PlotPyStack/PlotPy/issues/11) for the
original issue, even if the problem is not directly pointed out in the issue
comments.
- The issue was caused by the `QwtAbstractScaleDraw` cache mechanism, which was
keeping references to `QSizeF` objects that were deleted by the garbage collector
at some point. This was causing a segmentation fault, but only on Linux, and
only when executing the `PlotPy` test suite in a specific order.
- Thanks to @yuzibo for helping to reproduce the issue and providing a test case,
that is the `PlotPy` Debian package build process.

## Version 0.12.2

For this release, test coverage is 72%.
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.2"
__version__ = "0.12.3"
QWT_VERSION_STR = "6.1.5"


Expand Down
7 changes: 3 additions & 4 deletions qwt/scale_draw.py
Original file line number Diff line number Diff line change
Expand Up @@ -438,14 +438,13 @@ def tickLabel(self, font, value):
:param float value: Value
:return: Tuple (tick label, text size)
"""
lbl, tsize = self.__data.labelCache.get(value, (None, None))
lbl = self.__data.labelCache.get(value)
if lbl is None:
lbl = QwtText(self.label(value))
lbl.setRenderFlags(0)
lbl.setLayoutAttribute(QwtText.MinimumLayout)
tsize = lbl.textSize(font)
self.__data.labelCache[value] = lbl, tsize
return lbl, tsize
self.__data.labelCache[value] = lbl
return lbl, lbl.textSize(font)

def invalidateCache(self):
"""
Expand Down

0 comments on commit 018e23d

Please sign in to comment.