Skip to content

Commit 7dcb6cc

Browse files
committed
Revert QwtGraphic_PrivateData fix
1 parent 49d2938 commit 7dcb6cc

File tree

1 file changed

+16
-20
lines changed

1 file changed

+16
-20
lines changed

qwt/graphic.py

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -187,10 +187,10 @@ def scaleFactorY(self, pathRect, targetRect, scalePens):
187187

188188
class QwtGraphic_PrivateData(object):
189189
def __init__(self):
190-
self.boundingRect = None
191-
self.pointRect = None
190+
self.boundingRect = QRectF(0.0, 0.0, -1.0, -1.0)
191+
self.pointRect = QRectF(0.0, 0.0, -1.0, -1.0)
192192
self.initialTransform = None
193-
self.defaultSize = None
193+
self.defaultSize = QSizeF()
194194
self.commands = []
195195
self.pathInfos = []
196196
self.renderHints = 0
@@ -286,17 +286,17 @@ def reset(self):
286286
"""Clear all stored commands"""
287287
self.__data.commands = []
288288
self.__data.pathInfos = []
289-
self.__data.boundingRect = None
290-
self.__data.pointRect = None
291-
self.__data.defaultSize = None
289+
self.__data.boundingRect = QRectF(0.0, 0.0, -1.0, -1.0)
290+
self.__data.pointRect = QRectF(0.0, 0.0, -1.0, -1.0)
291+
self.__data.defaultSize = QSizeF()
292292

293293
def isNull(self):
294294
"""Return True, when no painter commands have been stored"""
295295
return len(self.__data.commands) == 0
296296

297297
def isEmpty(self):
298298
"""Return True, when the bounding rectangle is empty"""
299-
return self.__data.boundingRect is None or self.__data.boundingRect.isEmpty()
299+
return self.__data.boundingRect.isEmpty()
300300

301301
def setRenderHint(self, hint, on=True):
302302
"""Toggle an render hint"""
@@ -321,7 +321,7 @@ def boundingRect(self):
321321
322322
:py:meth:`controlPointRect`, :py:meth:`scaledBoundingRect`
323323
"""
324-
if self.__data.boundingRect is None or self.__data.boundingRect.width() < 0:
324+
if 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 or self.__data.pointRect.width() < 0:
340+
if self.__data.pointRect.width() < 0:
341341
return QRectF()
342342
return self.__data.pointRect
343343

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

@@ -489,11 +486,10 @@ def render(self, *args):
489486
return
490487
sx = 1.0
491488
sy = 1.0
492-
if self.__data.pointRect is not None:
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()
489+
if self.__data.pointRect.width() > 0.0:
490+
sx = rect.width() / self.__data.pointRect.width()
491+
if self.__data.pointRect.height() > 0.0:
492+
sy = rect.height() / self.__data.pointRect.height()
497493
scalePens = not bool(self.__data.renderHints & self.RenderPensUnscaled)
498494
for info in self.__data.pathInfos:
499495
ssx = info.scaleFactorX(self.__data.pointRect, rect, scalePens)
@@ -745,13 +741,13 @@ def updateBoundingRect(self, rect):
745741
cr = painter.clipRegion().boundingRect()
746742
cr = painter.transform().mapRect(cr)
747743
br &= cr
748-
if self.__data.boundingRect is None and self.__data.boundingRect.width() < 0:
744+
if self.__data.boundingRect.width() < 0:
749745
self.__data.boundingRect = br
750746
else:
751747
self.__data.boundingRect |= br
752748

753749
def updateControlPointRect(self, rect):
754-
if self.__data.pointRect is None and self.__data.pointRect.width() < 0.0:
750+
if self.__data.pointRect.width() < 0.0:
755751
self.__data.pointRect = rect
756752
else:
757753
self.__data.pointRect |= rect

0 commit comments

Comments
 (0)