diff options
author | Harald Fernengel <harald@trolltech.com> | 2009-06-15 12:17:17 (GMT) |
---|---|---|
committer | Harald Fernengel <harald@trolltech.com> | 2009-06-15 12:17:17 (GMT) |
commit | 217d263ee1feb5a0c2b19d634093f4c7975ac7c9 (patch) | |
tree | 72bdeece4c24b515926a6904b53d484e61b3d534 /src/gui/painting | |
parent | 2a91ca517826c8a4e5f432ad026106542f02f852 (diff) | |
download | Qt-217d263ee1feb5a0c2b19d634093f4c7975ac7c9.zip Qt-217d263ee1feb5a0c2b19d634093f4c7975ac7c9.tar.gz Qt-217d263ee1feb5a0c2b19d634093f4c7975ac7c9.tar.bz2 |
Fixes leak introduced by QScopedPointer
QPainterPath is kinda evil with a somewhat public private class and a
really private cast, so we need to up-cast the d pointer when deleting.
RevBy: aportale
Diffstat (limited to 'src/gui/painting')
-rw-r--r-- | src/gui/painting/qpainterpath.cpp | 18 | ||||
-rw-r--r-- | src/gui/painting/qpainterpath.h | 6 |
2 files changed, 21 insertions, 3 deletions
diff --git a/src/gui/painting/qpainterpath.cpp b/src/gui/painting/qpainterpath.cpp index 12dbc62..635218e 100644 --- a/src/gui/painting/qpainterpath.cpp +++ b/src/gui/painting/qpainterpath.cpp @@ -73,6 +73,24 @@ QT_BEGIN_NAMESPACE +struct QPainterPathPrivateHandler +{ + static inline void cleanup(QPainterPathPrivate *d) + { + // note - we must up-cast to QPainterPathData since QPainterPathPrivate + // has a non-virtual destructor! + if (d && !d->ref.deref()) + delete static_cast<QPainterPathData *>(d); + } + + static inline void reset(QPainterPathPrivate *&d, QPainterPathPrivate *other) + { + QPainterPathPrivate *oldD = d; + d = other; + cleanup(oldD); + } +}; + // This value is used to determine the length of control point vectors // when approximating arc segments as curves. The factor is multiplied // with the radius of the circle. diff --git a/src/gui/painting/qpainterpath.h b/src/gui/painting/qpainterpath.h index 0513593..e12194e 100644 --- a/src/gui/painting/qpainterpath.h +++ b/src/gui/painting/qpainterpath.h @@ -57,6 +57,7 @@ QT_MODULE(Gui) class QFont; class QPainterPathPrivate; +struct QPainterPathPrivateHandler; class QPainterPathData; class QPainterPathStrokerPrivate; class QPolygonF; @@ -196,7 +197,7 @@ public: QPainterPath &operator-=(const QPainterPath &other); private: - QScopedSharedPointer<QPainterPathPrivate> d_ptr; + QScopedCustomPointer<QPainterPathPrivate, QPainterPathPrivateHandler> d_ptr; inline void ensureData() { if (!d_ptr) ensureData_helper(); } void ensureData_helper(); @@ -230,8 +231,7 @@ public: friend class QPainterPathStrokerPrivate; friend class QMatrix; friend class QTransform; - friend class QScopedSharedPointer<QPainterPathPrivate>; - friend class QScopedSharedPointerHandler<QPainterPathPrivate>; + friend struct QPainterPathPrivateHandler; #ifndef QT_NO_DATASTREAM friend Q_GUI_EXPORT QDataStream &operator<<(QDataStream &, const QPainterPath &); friend Q_GUI_EXPORT QDataStream &operator>>(QDataStream &, QPainterPath &); |