core/renderlayerdelegate: remove QObject parent
Managing an object with both std::unique_ptr and a QObject parent at the same time is unnecessary and potentially dangerous
This commit is contained in:
parent
5553d0e0f4
commit
f90ec209d4
11 changed files with 17 additions and 43 deletions
|
@ -366,7 +366,7 @@ void Compositor::startupWithWorkspace()
|
|||
const QList<Output *> outputs = workspace()->outputs();
|
||||
if (kwinApp()->operationMode() == Application::OperationModeX11) {
|
||||
auto workspaceLayer = new RenderLayer(outputs.constFirst()->renderLoop());
|
||||
workspaceLayer->setDelegate(new SceneDelegate(m_scene.get()));
|
||||
workspaceLayer->setDelegate(std::make_unique<SceneDelegate>(m_scene.get()));
|
||||
workspaceLayer->setGeometry(workspace()->geometry());
|
||||
connect(workspace(), &Workspace::geometryChanged, workspaceLayer, [workspaceLayer]() {
|
||||
workspaceLayer->setGeometry(workspace()->geometry());
|
||||
|
@ -425,7 +425,7 @@ void Compositor::addOutput(Output *output)
|
|||
Q_ASSERT(kwinApp()->operationMode() != Application::OperationModeX11);
|
||||
|
||||
auto workspaceLayer = new RenderLayer(output->renderLoop());
|
||||
workspaceLayer->setDelegate(new SceneDelegate(m_scene.get(), output));
|
||||
workspaceLayer->setDelegate(std::make_unique<SceneDelegate>(m_scene.get(), output));
|
||||
workspaceLayer->setGeometry(output->rect());
|
||||
connect(output, &Output::geometryChanged, workspaceLayer, [output, workspaceLayer]() {
|
||||
workspaceLayer->setGeometry(output->rect());
|
||||
|
@ -434,9 +434,9 @@ void Compositor::addOutput(Output *output)
|
|||
auto cursorLayer = new RenderLayer(output->renderLoop());
|
||||
cursorLayer->setVisible(false);
|
||||
if (m_backend->compositingType() == OpenGLCompositing) {
|
||||
cursorLayer->setDelegate(new CursorDelegateOpenGL());
|
||||
cursorLayer->setDelegate(std::make_unique<CursorDelegateOpenGL>());
|
||||
} else {
|
||||
cursorLayer->setDelegate(new CursorDelegateQPainter());
|
||||
cursorLayer->setDelegate(std::make_unique<CursorDelegateQPainter>());
|
||||
}
|
||||
cursorLayer->setParent(workspaceLayer);
|
||||
cursorLayer->setSuperlayer(workspaceLayer);
|
||||
|
|
|
@ -95,9 +95,9 @@ RenderLayerDelegate *RenderLayer::delegate() const
|
|||
return m_delegate.get();
|
||||
}
|
||||
|
||||
void RenderLayer::setDelegate(RenderLayerDelegate *delegate)
|
||||
void RenderLayer::setDelegate(std::unique_ptr<RenderLayerDelegate> delegate)
|
||||
{
|
||||
m_delegate.reset(delegate);
|
||||
m_delegate = std::move(delegate);
|
||||
m_delegate->setLayer(this);
|
||||
}
|
||||
|
||||
|
|
|
@ -45,7 +45,7 @@ public:
|
|||
|
||||
RenderLoop *loop() const;
|
||||
RenderLayerDelegate *delegate() const;
|
||||
void setDelegate(RenderLayerDelegate *delegate);
|
||||
void setDelegate(std::unique_ptr<RenderLayerDelegate> delegate);
|
||||
|
||||
QList<RenderLayer *> sublayers() const;
|
||||
RenderLayer *superlayer() const;
|
||||
|
|
|
@ -9,11 +9,6 @@
|
|||
namespace KWin
|
||||
{
|
||||
|
||||
RenderLayerDelegate::RenderLayerDelegate(QObject *parent)
|
||||
: QObject(parent)
|
||||
{
|
||||
}
|
||||
|
||||
RenderLayer *RenderLayerDelegate::layer() const
|
||||
{
|
||||
return m_layer;
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
|
||||
#include "kwin_export.h"
|
||||
|
||||
#include <QObject>
|
||||
#include <QRegion>
|
||||
|
||||
namespace KWin
|
||||
|
@ -21,12 +20,10 @@ class SurfaceItem;
|
|||
/**
|
||||
* The RenderLayerDelegate class represents a render layer's contents.
|
||||
*/
|
||||
class KWIN_EXPORT RenderLayerDelegate : public QObject
|
||||
class KWIN_EXPORT RenderLayerDelegate
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit RenderLayerDelegate(QObject *parent = nullptr);
|
||||
virtual ~RenderLayerDelegate() = default;
|
||||
|
||||
RenderLayer *layer() const;
|
||||
void setLayer(RenderLayer *layer);
|
||||
|
|
|
@ -14,11 +14,6 @@
|
|||
namespace KWin
|
||||
{
|
||||
|
||||
CursorDelegateOpenGL::CursorDelegateOpenGL(QObject *parent)
|
||||
: RenderLayerDelegate(parent)
|
||||
{
|
||||
}
|
||||
|
||||
CursorDelegateOpenGL::~CursorDelegateOpenGL()
|
||||
{
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
*/
|
||||
|
||||
#pragma once
|
||||
#include <QObject>
|
||||
#include <memory>
|
||||
|
||||
#include "core/renderlayerdelegate.h"
|
||||
|
@ -14,12 +15,11 @@ namespace KWin
|
|||
|
||||
class GLTexture;
|
||||
|
||||
class CursorDelegateOpenGL final : public RenderLayerDelegate
|
||||
class CursorDelegateOpenGL final : public QObject, public RenderLayerDelegate
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit CursorDelegateOpenGL(QObject *parent = nullptr);
|
||||
~CursorDelegateOpenGL() override;
|
||||
|
||||
void paint(RenderTarget *renderTarget, const QRegion ®ion) override;
|
||||
|
|
|
@ -14,11 +14,6 @@
|
|||
namespace KWin
|
||||
{
|
||||
|
||||
CursorDelegateQPainter::CursorDelegateQPainter(QObject *parent)
|
||||
: RenderLayerDelegate(parent)
|
||||
{
|
||||
}
|
||||
|
||||
void CursorDelegateQPainter::paint(RenderTarget *renderTarget, const QRegion ®ion)
|
||||
{
|
||||
if (!region.intersects(layer()->mapToGlobal(layer()->rect()))) {
|
||||
|
|
|
@ -13,11 +13,7 @@ namespace KWin
|
|||
|
||||
class CursorDelegateQPainter final : public RenderLayerDelegate
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit CursorDelegateQPainter(QObject *parent = nullptr);
|
||||
|
||||
void paint(RenderTarget *renderTarget, const QRegion ®ion) override;
|
||||
};
|
||||
|
||||
|
|
|
@ -79,16 +79,14 @@
|
|||
namespace KWin
|
||||
{
|
||||
|
||||
SceneDelegate::SceneDelegate(Scene *scene, QObject *parent)
|
||||
: RenderLayerDelegate(parent)
|
||||
, m_scene(scene)
|
||||
SceneDelegate::SceneDelegate(Scene *scene)
|
||||
: m_scene(scene)
|
||||
{
|
||||
m_scene->addDelegate(this);
|
||||
}
|
||||
|
||||
SceneDelegate::SceneDelegate(Scene *scene, Output *output, QObject *parent)
|
||||
: RenderLayerDelegate(parent)
|
||||
, m_scene(scene)
|
||||
SceneDelegate::SceneDelegate(Scene *scene, Output *output)
|
||||
: m_scene(scene)
|
||||
, m_output(output)
|
||||
{
|
||||
m_scene->addDelegate(this);
|
||||
|
|
|
@ -44,11 +44,9 @@ class WindowItem;
|
|||
|
||||
class SceneDelegate : public RenderLayerDelegate
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit SceneDelegate(Scene *scene, QObject *parent = nullptr);
|
||||
explicit SceneDelegate(Scene *scene, Output *output, QObject *parent = nullptr);
|
||||
explicit SceneDelegate(Scene *scene);
|
||||
explicit SceneDelegate(Scene *scene, Output *output);
|
||||
~SceneDelegate() override;
|
||||
|
||||
Output *output() const;
|
||||
|
|
Loading…
Reference in a new issue