diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/corelib/tools/qscopedpointer.h | 9 | ||||
-rw-r--r-- | src/gui/painting/qbrush.cpp | 14 | ||||
-rw-r--r-- | src/gui/painting/qbrush.h | 6 |
3 files changed, 19 insertions, 10 deletions
diff --git a/src/corelib/tools/qscopedpointer.h b/src/corelib/tools/qscopedpointer.h index 7a3ee14..f801366 100644 --- a/src/corelib/tools/qscopedpointer.h +++ b/src/corelib/tools/qscopedpointer.h @@ -166,6 +166,11 @@ public: return oldD; } + inline void swap(QScopedPointer<T, Cleanup> &other) + { + qSwap(d, other.d); + } + typedef T *pointer; protected: @@ -175,6 +180,10 @@ private: Q_DISABLE_COPY(QScopedPointer) }; +template <class T, class Cleanup> +Q_INLINE_TEMPLATE void qSwap(QScopedPointer<T, Cleanup> &p1, QScopedPointer<T, Cleanup> &p2) +{ p1.swap(p2); } + template <typename T, typename Cleanup = QScopedPointerArrayDeleter<T> > class QScopedArrayPointer : public QScopedPointer<T, Cleanup> { diff --git a/src/gui/painting/qbrush.cpp b/src/gui/painting/qbrush.cpp index b005842..a52a270 100644 --- a/src/gui/painting/qbrush.cpp +++ b/src/gui/painting/qbrush.cpp @@ -389,20 +389,20 @@ void QBrush::init(const QColor &color, Qt::BrushStyle style) { switch(style) { case Qt::NoBrush: - d.data_ptr() = nullBrushInstance(); + d.reset(nullBrushInstance()); d->ref.ref(); if (d->color != color) setColor(color); return; case Qt::TexturePattern: - d.data_ptr() = new QTexturedBrushData; + d.reset(new QTexturedBrushData); break; case Qt::LinearGradientPattern: case Qt::RadialGradientPattern: case Qt::ConicalGradientPattern: - d.data_ptr() = new QGradientBrushData; + d.reset(new QGradientBrushData); break; default: - d.data_ptr() = new QBrushData; + d.reset(new QBrushData); break; } d->ref = 1; @@ -460,7 +460,7 @@ QBrush::QBrush(Qt::BrushStyle style) if (qbrush_check_type(style)) init(Qt::black, style); else { - d.data_ptr() = nullBrushInstance(); + d.reset(nullBrushInstance()); d->ref.ref(); } } @@ -476,7 +476,7 @@ QBrush::QBrush(const QColor &color, Qt::BrushStyle style) if (qbrush_check_type(style)) init(color, style); else { - d.data_ptr() = nullBrushInstance(); + d.reset(nullBrushInstance()); d->ref.ref(); } } @@ -493,7 +493,7 @@ QBrush::QBrush(Qt::GlobalColor color, Qt::BrushStyle style) if (qbrush_check_type(style)) init(color, style); else { - d.data_ptr() = nullBrushInstance(); + d.reset(nullBrushInstance()); d->ref.ref(); } } diff --git a/src/gui/painting/qbrush.h b/src/gui/painting/qbrush.h index 51b108e..9f9819c 100644 --- a/src/gui/painting/qbrush.h +++ b/src/gui/painting/qbrush.h @@ -137,13 +137,13 @@ private: friend bool Q_GUI_EXPORT qHasPixmapTexture(const QBrush& brush); void detach(Qt::BrushStyle newStyle); void init(const QColor &color, Qt::BrushStyle bs); - QCustomScopedPointer<QBrushData, QBrushDataPointerDeleter> d; + QScopedPointer<QBrushData, QBrushDataPointerDeleter> d; void cleanUp(QBrushData *x); public: inline bool isDetached() const; - typedef QBrushData * DataPtr; - inline DataPtr &data_ptr() { return d.data_ptr(); } + typedef QScopedPointer<QBrushData, QBrushDataPointerDeleter> DataPtr; + inline DataPtr &data_ptr() { return d; } }; inline void QBrush::setColor(Qt::GlobalColor acolor) |