Composition example: use std::unique_ptr instead of QScopedPointer
The use of a unique_ptr member requires that the destructor be out-of-line, since the payload is only forward-declared in the header file. This is good hygiene, so do it for CompositionWidget, too. Add 'explicit' and missing = nullptr to both constructors as a drive-by. Change-Id: Ied1c89864f90d3f2c13fb4e9a8bbbe2e6fd6f1d7 Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
This commit is contained in:
parent
4469e36d72
commit
8ab4d2028f
@ -224,6 +224,10 @@ CompositionWidget::CompositionWidget(QWidget *parent)
|
||||
setWindowTitle(tr("Composition Modes"));
|
||||
}
|
||||
|
||||
CompositionWidget::~CompositionWidget()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void CompositionWidget::nextMode()
|
||||
{
|
||||
@ -265,6 +269,10 @@ CompositionRenderer::CompositionRenderer(QWidget *parent)
|
||||
#endif
|
||||
}
|
||||
|
||||
CompositionRenderer::~CompositionRenderer()
|
||||
{
|
||||
}
|
||||
|
||||
QRectF rectangle_around(const QPointF &p, const QSizeF &size = QSize(250, 200))
|
||||
{
|
||||
QRectF rect(p, size);
|
||||
@ -371,7 +379,7 @@ void CompositionRenderer::paint(QPainter *painter)
|
||||
|
||||
if (size() != m_previous_size) {
|
||||
m_previous_size = size();
|
||||
QPainter p(m_fbo.data());
|
||||
QPainter p(m_fbo.get());
|
||||
p.setCompositionMode(QPainter::CompositionMode_Source);
|
||||
p.fillRect(QRect(QPoint(0, 0), size()), Qt::transparent);
|
||||
p.setCompositionMode(QPainter::CompositionMode_SourceOver);
|
||||
@ -382,7 +390,7 @@ void CompositionRenderer::paint(QPainter *painter)
|
||||
|
||||
painter->beginNativePainting();
|
||||
{
|
||||
QPainter p(m_fbo.data());
|
||||
QPainter p(m_fbo.get());
|
||||
p.beginNativePainting();
|
||||
m_blitter.bind();
|
||||
const QRect targetRect(QPoint(0, 0), m_fbo->size());
|
||||
|
@ -61,6 +61,8 @@
|
||||
#include <QPainter>
|
||||
#include <QEvent>
|
||||
|
||||
#include <memory>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QPushButton;
|
||||
class QRadioButton;
|
||||
@ -71,7 +73,8 @@ class CompositionWidget : public QWidget
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
CompositionWidget(QWidget *parent);
|
||||
explicit CompositionWidget(QWidget *parent = nullptr);
|
||||
~CompositionWidget();
|
||||
|
||||
public slots:
|
||||
void nextMode();
|
||||
@ -117,7 +120,8 @@ class CompositionRenderer : public ArthurFrame
|
||||
Q_PROPERTY(bool animation READ animationEnabled WRITE setAnimationEnabled)
|
||||
|
||||
public:
|
||||
CompositionRenderer(QWidget *parent);
|
||||
explicit CompositionRenderer(QWidget *parent = nullptr);
|
||||
~CompositionRenderer();
|
||||
|
||||
void paint(QPainter *) override;
|
||||
|
||||
@ -188,7 +192,7 @@ private:
|
||||
int m_animationTimer;
|
||||
|
||||
#if QT_CONFIG(opengl)
|
||||
QScopedPointer<QFboPaintDevice> m_fbo;
|
||||
std::unique_ptr<QFboPaintDevice> m_fbo;
|
||||
int m_pbuffer_size; // width==height==size of pbuffer
|
||||
uint m_base_tex;
|
||||
uint m_compositing_tex;
|
||||
|
Loading…
Reference in New Issue
Block a user