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:
parent
b7c7beacda
commit
fc65b9a7cb
@ -83,6 +83,7 @@
|
|||||||
#include "qgraphicswidget.h"
|
#include "qgraphicswidget.h"
|
||||||
#include "qgraphicsgridlayoutengine_p.h"
|
#include "qgraphicsgridlayoutengine_p.h"
|
||||||
#include "qgraphicslayoutstyleinfo_p.h"
|
#include "qgraphicslayoutstyleinfo_p.h"
|
||||||
|
#include "qscopedpointer.h"
|
||||||
#ifdef QT_DEBUG
|
#ifdef QT_DEBUG
|
||||||
# include <QtCore/qdebug.h>
|
# include <QtCore/qdebug.h>
|
||||||
#endif
|
#endif
|
||||||
@ -92,10 +93,10 @@ QT_BEGIN_NAMESPACE
|
|||||||
class QGraphicsGridLayoutPrivate : public QGraphicsLayoutPrivate
|
class QGraphicsGridLayoutPrivate : public QGraphicsLayoutPrivate
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
QGraphicsGridLayoutPrivate(): m_styleInfo(0) { }
|
QGraphicsGridLayoutPrivate() { }
|
||||||
QGraphicsLayoutStyleInfo *styleInfo() const;
|
QGraphicsLayoutStyleInfo *styleInfo() const;
|
||||||
|
|
||||||
mutable QGraphicsLayoutStyleInfo *m_styleInfo;
|
mutable QScopedPointer<QGraphicsLayoutStyleInfo> m_styleInfo;
|
||||||
QGraphicsGridLayoutEngine engine;
|
QGraphicsGridLayoutEngine engine;
|
||||||
|
|
||||||
#ifdef QGRIDLAYOUTENGINE_DEBUG
|
#ifdef QGRIDLAYOUTENGINE_DEBUG
|
||||||
@ -107,8 +108,8 @@ public:
|
|||||||
QGraphicsLayoutStyleInfo *QGraphicsGridLayoutPrivate::styleInfo() const
|
QGraphicsLayoutStyleInfo *QGraphicsGridLayoutPrivate::styleInfo() const
|
||||||
{
|
{
|
||||||
if (!m_styleInfo)
|
if (!m_styleInfo)
|
||||||
m_styleInfo = new QGraphicsLayoutStyleInfo(this);
|
m_styleInfo.reset(new QGraphicsLayoutStyleInfo(this));
|
||||||
return m_styleInfo;
|
return m_styleInfo.data();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
@ -116,6 +116,7 @@
|
|||||||
#include "qgraphicswidget.h"
|
#include "qgraphicswidget.h"
|
||||||
#include "qgraphicsgridlayoutengine_p.h"
|
#include "qgraphicsgridlayoutengine_p.h"
|
||||||
#include "qgraphicslayoutstyleinfo_p.h"
|
#include "qgraphicslayoutstyleinfo_p.h"
|
||||||
|
#include "qscopedpointer.h"
|
||||||
#ifdef QT_DEBUG
|
#ifdef QT_DEBUG
|
||||||
#include <QtCore/qdebug.h>
|
#include <QtCore/qdebug.h>
|
||||||
#endif
|
#endif
|
||||||
@ -126,8 +127,7 @@ class QGraphicsLinearLayoutPrivate : public QGraphicsLayoutPrivate
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
QGraphicsLinearLayoutPrivate(Qt::Orientation orientation)
|
QGraphicsLinearLayoutPrivate(Qt::Orientation orientation)
|
||||||
: orientation(orientation),
|
: orientation(orientation)
|
||||||
m_styleInfo(0)
|
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
void removeGridItem(QGridLayoutItem *gridItem);
|
void removeGridItem(QGridLayoutItem *gridItem);
|
||||||
@ -137,7 +137,7 @@ public:
|
|||||||
int gridColumn(int index) const;
|
int gridColumn(int index) const;
|
||||||
|
|
||||||
Qt::Orientation orientation;
|
Qt::Orientation orientation;
|
||||||
mutable QGraphicsLayoutStyleInfo *m_styleInfo;
|
mutable QScopedPointer<QGraphicsLayoutStyleInfo> m_styleInfo;
|
||||||
QGraphicsGridLayoutEngine engine;
|
QGraphicsGridLayoutEngine engine;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -172,8 +172,8 @@ int QGraphicsLinearLayoutPrivate::gridColumn(int index) const
|
|||||||
QGraphicsLayoutStyleInfo *QGraphicsLinearLayoutPrivate::styleInfo() const
|
QGraphicsLayoutStyleInfo *QGraphicsLinearLayoutPrivate::styleInfo() const
|
||||||
{
|
{
|
||||||
if (!m_styleInfo)
|
if (!m_styleInfo)
|
||||||
m_styleInfo = new QGraphicsLayoutStyleInfo(this);
|
m_styleInfo.reset(new QGraphicsLayoutStyleInfo(this));
|
||||||
return m_styleInfo;
|
return m_styleInfo.data();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
Loading…
x
Reference in New Issue
Block a user