Skip to content

Commit 5387329

Browse files
committed
QwtGraphic_PrivateData: more conservative changes
1 parent f00ad28 commit 5387329

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

qwt/graphic.py

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ def boundingRect(self):
321321
322322
:py:meth:`controlPointRect`, :py:meth:`scaledBoundingRect`
323323
"""
324-
if self.__data.boundingRect is None:
324+
if self.__data.boundingRect is None or self.__data.boundingRect.width() < 0:
325325
return QRectF()
326326
return self.__data.boundingRect
327327

@@ -337,7 +337,7 @@ def controlPointRect(self):
337337
338338
:py:meth:`boundingRect()`, :py:meth:`scaledBoundingRect()`
339339
"""
340-
if self.__data.pointRect is None:
340+
if self.__data.pointRect is None or self.__data.pointRect.width() < 0:
341341
return QRectF()
342342
return self.__data.pointRect
343343

@@ -407,7 +407,10 @@ def defaultSize(self):
407407
408408
:py:meth:`setDefaultSize()`, :py:meth:`boundingRect()`
409409
"""
410-
if self.__data.defaultSize is not None:
410+
if (
411+
self.__data.defaultSize is not None
412+
and not self.__data.defaultSize.isEmpty()
413+
):
411414
return self.__data.defaultSize
412415
return self.boundingRect().size()
413416

@@ -487,9 +490,10 @@ def render(self, *args):
487490
sx = 1.0
488491
sy = 1.0
489492
if self.__data.pointRect is not None:
490-
sx = rect.width() / self.__data.pointRect.width()
491-
if self.__data.pointRect is not None:
492-
sy = rect.height() / self.__data.pointRect.height()
493+
if self.__data.pointRect.width() > 0.0:
494+
sx = rect.width() / self.__data.pointRect.width()
495+
if self.__data.pointRect.height() > 0.0:
496+
sy = rect.height() / self.__data.pointRect.height()
493497
scalePens = not bool(self.__data.renderHints & self.RenderPensUnscaled)
494498
for info in self.__data.pathInfos:
495499
ssx = info.scaleFactorX(self.__data.pointRect, rect, scalePens)
@@ -741,13 +745,13 @@ def updateBoundingRect(self, rect):
741745
cr = painter.clipRegion().boundingRect()
742746
cr = painter.transform().mapRect(cr)
743747
br &= cr
744-
if self.__data.boundingRect is None:
748+
if self.__data.boundingRect is None and self.__data.boundingRect.width() < 0:
745749
self.__data.boundingRect = br
746750
else:
747751
self.__data.boundingRect |= br
748752

749753
def updateControlPointRect(self, rect):
750-
if self.__data.pointRect is None:
754+
if self.__data.pointRect is None and self.__data.pointRect.width() < 0.0:
751755
self.__data.pointRect = rect
752756
else:
753757
self.__data.pointRect |= rect

0 commit comments

Comments
 (0)