qgraphicslayoutstyleinfo: Improve memory handling
Change-Id: I3d699a89e8833570132cbd03aa575e4f4cf9249b Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>bb10
parent
83bf7d8260
commit
a8dae3ad0b
|
|
@ -50,14 +50,13 @@ QT_BEGIN_NAMESPACE
|
|||
QGraphicsLayoutStyleInfo::QGraphicsLayoutStyleInfo(const QGraphicsLayoutPrivate *layout)
|
||||
: m_layout(layout), m_style(0)
|
||||
{
|
||||
m_widget = new QWidget; // pixelMetric might need a widget ptr
|
||||
m_styleOption.initFrom(m_widget);
|
||||
m_widget.reset(new QWidget); // pixelMetric might need a widget ptr
|
||||
m_styleOption.initFrom(m_widget.get());
|
||||
m_isWindow = m_styleOption.state & QStyle::State_Window;
|
||||
}
|
||||
|
||||
QGraphicsLayoutStyleInfo::~QGraphicsLayoutStyleInfo()
|
||||
{
|
||||
delete m_widget;
|
||||
}
|
||||
|
||||
qreal QGraphicsLayoutStyleInfo::combinedLayoutSpacing(QLayoutPolicy::ControlTypes controls1,
|
||||
|
|
@ -92,7 +91,7 @@ qreal QGraphicsLayoutStyleInfo::windowMargin(Qt::Orientation orientation) const
|
|||
const_cast<QStyleOption*>(&m_styleOption), widget());
|
||||
}
|
||||
|
||||
QWidget *QGraphicsLayoutStyleInfo::widget() const { return m_widget; }
|
||||
QWidget *QGraphicsLayoutStyleInfo::widget() const { return m_widget.get(); }
|
||||
|
||||
QStyle *QGraphicsLayoutStyleInfo::style() const
|
||||
{
|
||||
|
|
|
|||
|
|
@ -54,6 +54,8 @@
|
|||
#include <QtGui/private/qabstractlayoutstyleinfo_p.h>
|
||||
#include <QtWidgets/qstyleoption.h>
|
||||
|
||||
#include <memory>
|
||||
|
||||
QT_REQUIRE_CONFIG(graphicsview);
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
|
@ -93,7 +95,7 @@ private:
|
|||
const QGraphicsLayoutPrivate *m_layout;
|
||||
mutable QStyle *m_style;
|
||||
QStyleOption m_styleOption;
|
||||
QWidget *m_widget;
|
||||
std::unique_ptr<QWidget> m_widget;
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
|
|
|||
Loading…
Reference in New Issue