backends/drm: extend connector lifetime to match their outputs

As disconnected outputs outlive DrmGpu::updateOutputs, the DrmConnector
and DrmPipeline must also be kept valid for that time

BUG: 463334
This commit is contained in:
Xaver Hugl 2022-12-28 23:06:55 +01:00
parent ccaf0210d1
commit 239207c5ee
4 changed files with 10 additions and 11 deletions

View file

@ -253,7 +253,7 @@ bool DrmGpu::updateOutputs()
return connector->id() == currentConnector; return connector->id() == currentConnector;
}); });
if (it == m_connectors.end()) { if (it == m_connectors.end()) {
auto conn = std::make_unique<DrmConnector>(this, currentConnector); auto conn = std::make_shared<DrmConnector>(this, currentConnector);
if (!conn->init()) { if (!conn->init()) {
continue; continue;
} }
@ -278,7 +278,7 @@ bool DrmGpu::updateOutputs()
qCDebug(KWIN_DRM, "New %soutput on GPU %s: %s", conn->isNonDesktop() ? "non-desktop " : "", qPrintable(m_devNode), qPrintable(conn->modelName())); qCDebug(KWIN_DRM, "New %soutput on GPU %s: %s", conn->isNonDesktop() ? "non-desktop " : "", qPrintable(m_devNode), qPrintable(conn->modelName()));
const auto pipeline = conn->pipeline(); const auto pipeline = conn->pipeline();
m_pipelines << pipeline; m_pipelines << pipeline;
auto output = new DrmOutput(pipeline); auto output = new DrmOutput(*it);
m_drmOutputs << output; m_drmOutputs << output;
addedOutputs << output; addedOutputs << output;
Q_EMIT outputAdded(output); Q_EMIT outputAdded(output);

View file

@ -139,7 +139,7 @@ private:
std::vector<std::unique_ptr<DrmPlane>> m_planes; std::vector<std::unique_ptr<DrmPlane>> m_planes;
std::vector<std::unique_ptr<DrmCrtc>> m_crtcs; std::vector<std::unique_ptr<DrmCrtc>> m_crtcs;
std::vector<std::unique_ptr<DrmConnector>> m_connectors; std::vector<std::shared_ptr<DrmConnector>> m_connectors;
QVector<DrmObject *> m_allObjects; QVector<DrmObject *> m_allObjects;
QVector<DrmPipeline *> m_pipelines; QVector<DrmPipeline *> m_pipelines;

View file

@ -38,14 +38,13 @@
namespace KWin namespace KWin
{ {
DrmOutput::DrmOutput(DrmPipeline *pipeline) DrmOutput::DrmOutput(const std::shared_ptr<DrmConnector> &conn)
: DrmAbstractOutput(pipeline->connector()->gpu()) : DrmAbstractOutput(conn->gpu())
, m_pipeline(pipeline) , m_pipeline(conn->pipeline())
, m_connector(pipeline->connector()) , m_connector(conn)
{ {
RenderLoopPrivate::get(m_renderLoop.get())->canDoTearing = gpu()->asyncPageflipSupported(); RenderLoopPrivate::get(m_renderLoop.get())->canDoTearing = gpu()->asyncPageflipSupported();
m_pipeline->setOutput(this); m_pipeline->setOutput(this);
const auto conn = m_pipeline->connector();
m_renderLoop->setRefreshRate(m_pipeline->mode()->refreshRate()); m_renderLoop->setRefreshRate(m_pipeline->mode()->refreshRate());
Capabilities capabilities = Capability::Dpms; Capabilities capabilities = Capability::Dpms;
@ -387,7 +386,7 @@ bool DrmOutput::present()
DrmConnector *DrmOutput::connector() const DrmConnector *DrmOutput::connector() const
{ {
return m_connector; return m_connector.get();
} }
DrmPipeline *DrmOutput::pipeline() const DrmPipeline *DrmOutput::pipeline() const

View file

@ -35,7 +35,7 @@ class KWIN_EXPORT DrmOutput : public DrmAbstractOutput
{ {
Q_OBJECT Q_OBJECT
public: public:
DrmOutput(DrmPipeline *pipeline); DrmOutput(const std::shared_ptr<DrmConnector> &connector);
~DrmOutput() override; ~DrmOutput() override;
DrmConnector *connector() const; DrmConnector *connector() const;
@ -71,7 +71,7 @@ private:
void renderCursorQPainter(const RenderTarget &renderTarget); void renderCursorQPainter(const RenderTarget &renderTarget);
DrmPipeline *m_pipeline; DrmPipeline *m_pipeline;
DrmConnector *m_connector; const std::shared_ptr<DrmConnector> m_connector;
bool m_setCursorSuccessful = false; bool m_setCursorSuccessful = false;
bool m_moveCursorSuccessful = false; bool m_moveCursorSuccessful = false;