QGraphics*Layout: fix memory leaks

Change-Id: I5f9d2ccc8912e3fa08e376b5f6b6450d22913406
Task-number: QTBUG-10768
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@theqtcompany.com>
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
This commit is contained in:
Giuseppe D'Angelo 2016-03-31 21:15:30 +02:00
parent b7c7beacda
commit fc65b9a7cb
2 changed files with 10 additions and 9 deletions

View File

@ -83,6 +83,7 @@
#include "qgraphicswidget.h"
#include "qgraphicsgridlayoutengine_p.h"
#include "qgraphicslayoutstyleinfo_p.h"
#include "qscopedpointer.h"
#ifdef QT_DEBUG
# include <QtCore/qdebug.h>
#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<QGraphicsLayoutStyleInfo> 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();
}
/*!

View File

@ -116,6 +116,7 @@
#include "qgraphicswidget.h"
#include "qgraphicsgridlayoutengine_p.h"
#include "qgraphicslayoutstyleinfo_p.h"
#include "qscopedpointer.h"
#ifdef QT_DEBUG
#include <QtCore/qdebug.h>
#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<QGraphicsLayoutStyleInfo> 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();
}
/*!