diff --git a/CHANGELOG.md b/CHANGELOG.md index f32e145..10a18f4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # PythonQwt Releases +## Version 0.12.7 + +- Fixed other random crashes (segfaults) on Linux related to Qt objects stored in + private data structures (`QwtGraphic_PrivateData`, `QwtLegendLabel_PrivateData`) + ## Version 0.12.6 - Fixed random crashes (segfaults) on Linux related to Qt objects stored in cache data diff --git a/qwt/graphic.py b/qwt/graphic.py index 1eccc34..51bfd13 100644 --- a/qwt/graphic.py +++ b/qwt/graphic.py @@ -187,10 +187,10 @@ def scaleFactorY(self, pathRect, targetRect, scalePens): class QwtGraphic_PrivateData(object): def __init__(self): - self.boundingRect = QRectF(0.0, 0.0, -1.0, -1.0) - self.pointRect = QRectF(0.0, 0.0, -1.0, -1.0) + self.boundingRect = None + self.pointRect = None self.initialTransform = None - self.defaultSize = QSizeF() + self.defaultSize = None self.commands = [] self.pathInfos = [] self.renderHints = 0 @@ -286,9 +286,9 @@ def reset(self): """Clear all stored commands""" self.__data.commands = [] self.__data.pathInfos = [] - self.__data.boundingRect = QRectF(0.0, 0.0, -1.0, -1.0) - self.__data.pointRect = QRectF(0.0, 0.0, -1.0, -1.0) - self.__data.defaultSize = QSizeF() + self.__data.boundingRect = None + self.__data.pointRect = None + self.__data.defaultSize = None def isNull(self): """Return True, when no painter commands have been stored""" @@ -296,7 +296,7 @@ def isNull(self): def isEmpty(self): """Return True, when the bounding rectangle is empty""" - return self.__data.boundingRect.isEmpty() + return self.__data.boundingRect is None or self.__data.boundingRect.isEmpty() def setRenderHint(self, hint, on=True): """Toggle an render hint""" @@ -321,7 +321,7 @@ def boundingRect(self): :py:meth:`controlPointRect`, :py:meth:`scaledBoundingRect` """ - if self.__data.boundingRect.width() < 0: + if self.__data.boundingRect is None: return QRectF() return self.__data.boundingRect @@ -337,7 +337,7 @@ def controlPointRect(self): :py:meth:`boundingRect()`, :py:meth:`scaledBoundingRect()` """ - if self.__data.pointRect.width() < 0: + if self.__data.pointRect is None: return QRectF() return self.__data.pointRect @@ -407,7 +407,7 @@ def defaultSize(self): :py:meth:`setDefaultSize()`, :py:meth:`boundingRect()` """ - if not self.__data.defaultSize.isEmpty(): + if self.__data.defaultSize is not None: return self.__data.defaultSize return self.boundingRect().size() @@ -486,9 +486,9 @@ def render(self, *args): return sx = 1.0 sy = 1.0 - if self.__data.pointRect.width() > 0.0: + if self.__data.pointRect is not None: sx = rect.width() / self.__data.pointRect.width() - if self.__data.pointRect.height() > 0.0: + if self.__data.pointRect is not None: sy = rect.height() / self.__data.pointRect.height() scalePens = not bool(self.__data.renderHints & self.RenderPensUnscaled) for info in self.__data.pathInfos: @@ -741,13 +741,13 @@ def updateBoundingRect(self, rect): cr = painter.clipRegion().boundingRect() cr = painter.transform().mapRect(cr) br &= cr - if self.__data.boundingRect.width() < 0: + if self.__data.boundingRect is None: self.__data.boundingRect = br else: self.__data.boundingRect |= br def updateControlPointRect(self, rect): - if self.__data.pointRect.width() < 0.0: + if self.__data.pointRect is None: self.__data.pointRect = rect else: self.__data.pointRect |= rect diff --git a/qwt/legend.py b/qwt/legend.py index 86030c3..5b516d3 100644 --- a/qwt/legend.py +++ b/qwt/legend.py @@ -176,7 +176,7 @@ def __init__(self): self.isDown = False self.spacing = MARGIN self.legendData = QwtLegendData() - self.icon = QPixmap() + self.icon = None class QwtLegendLabel(QwtTextLabel): @@ -294,7 +294,7 @@ def icon(self): :py:meth:`setIcon()` """ - return self.__data.icon + return QPixmap() if self.__data.icon is None else self.__data.icon def setSpacing(self, spacing): """ @@ -312,7 +312,7 @@ def setSpacing(self, spacing): mgn = self.contentsMargins() margin = max([mgn.left(), mgn.top(), mgn.right(), mgn.bottom()]) indent = margin + self.__data.spacing - if self.__data.icon.width() > 0: + if self.__data.icon is not None: indent += self.__data.icon.width() + self.__data.spacing self.setIndent(indent) @@ -409,7 +409,7 @@ def paintEvent(self, e): painter.translate(shiftSize.width(), shiftSize.height()) painter.setClipRect(cr) self.drawContents(painter) - if not self.__data.icon.isNull(): + if self.__data.icon is not None: iconRect = QRect(cr) iconRect.setX(iconRect.x() + self.margin()) if self.__data.itemMode != QwtLegendData.ReadOnly: