diff --git a/src/widgets/graphicsview/qgraphicsgridlayout.cpp b/src/widgets/graphicsview/qgraphicsgridlayout.cpp index 6f65558a1a..2dc84a5399 100644 --- a/src/widgets/graphicsview/qgraphicsgridlayout.cpp +++ b/src/widgets/graphicsview/qgraphicsgridlayout.cpp @@ -83,6 +83,7 @@ #include "qgraphicswidget.h" #include "qgraphicsgridlayoutengine_p.h" #include "qgraphicslayoutstyleinfo_p.h" +#include "qscopedpointer.h" #ifdef QT_DEBUG # include #endif @@ -92,10 +93,10 @@ QT_BEGIN_NAMESPACE class QGraphicsGridLayoutPrivate : public QGraphicsLayoutPrivate { public: - QGraphicsGridLayoutPrivate(): m_styleInfo(0) { } + QGraphicsGridLayoutPrivate() { } QGraphicsLayoutStyleInfo *styleInfo() const; - mutable QGraphicsLayoutStyleInfo *m_styleInfo; + mutable QScopedPointer m_styleInfo; QGraphicsGridLayoutEngine engine; #ifdef QGRIDLAYOUTENGINE_DEBUG @@ -107,8 +108,8 @@ public: QGraphicsLayoutStyleInfo *QGraphicsGridLayoutPrivate::styleInfo() const { if (!m_styleInfo) - m_styleInfo = new QGraphicsLayoutStyleInfo(this); - return m_styleInfo; + m_styleInfo.reset(new QGraphicsLayoutStyleInfo(this)); + return m_styleInfo.data(); } /*! diff --git a/src/widgets/graphicsview/qgraphicslinearlayout.cpp b/src/widgets/graphicsview/qgraphicslinearlayout.cpp index 0384364ad4..91e0fff60f 100644 --- a/src/widgets/graphicsview/qgraphicslinearlayout.cpp +++ b/src/widgets/graphicsview/qgraphicslinearlayout.cpp @@ -116,6 +116,7 @@ #include "qgraphicswidget.h" #include "qgraphicsgridlayoutengine_p.h" #include "qgraphicslayoutstyleinfo_p.h" +#include "qscopedpointer.h" #ifdef QT_DEBUG #include #endif @@ -126,8 +127,7 @@ class QGraphicsLinearLayoutPrivate : public QGraphicsLayoutPrivate { public: QGraphicsLinearLayoutPrivate(Qt::Orientation orientation) - : orientation(orientation), - m_styleInfo(0) + : orientation(orientation) { } void removeGridItem(QGridLayoutItem *gridItem); @@ -137,7 +137,7 @@ public: int gridColumn(int index) const; Qt::Orientation orientation; - mutable QGraphicsLayoutStyleInfo *m_styleInfo; + mutable QScopedPointer m_styleInfo; QGraphicsGridLayoutEngine engine; }; @@ -172,8 +172,8 @@ int QGraphicsLinearLayoutPrivate::gridColumn(int index) const QGraphicsLayoutStyleInfo *QGraphicsLinearLayoutPrivate::styleInfo() const { if (!m_styleInfo) - m_styleInfo = new QGraphicsLayoutStyleInfo(this); - return m_styleInfo; + m_styleInfo.reset(new QGraphicsLayoutStyleInfo(this)); + return m_styleInfo.data(); } /*!