backends/drm: don't access nullptr output configs

This commit is contained in:
Xaver Hugl 2023-03-31 01:22:48 +02:00 committed by Vlad Zahorodnii
parent 050336e421
commit f70be829c6
3 changed files with 12 additions and 10 deletions

View file

@ -474,7 +474,7 @@ bool DrmBackend::applyOutputChanges(const OutputConfiguration &config)
continue;
}
if (const auto changeset = config.constChangeSet(output)) {
output->queueChanges(config);
output->queueChanges(changeset);
if (changeset->enabled) {
toBeEnabled << output;
} else {
@ -495,10 +495,14 @@ bool DrmBackend::applyOutputChanges(const OutputConfiguration &config)
// first, apply changes to drm outputs.
// This may remove the placeholder output and thus change m_outputs!
for (const auto &output : std::as_const(toBeEnabled)) {
output->applyQueuedChanges(config);
if (const auto changeset = config.constChangeSet(output)) {
output->applyQueuedChanges(changeset);
}
}
for (const auto &output : std::as_const(toBeDisabled)) {
output->applyQueuedChanges(config);
if (const auto changeset = config.constChangeSet(output)) {
output->applyQueuedChanges(changeset);
}
}
// only then apply changes to the virtual outputs
for (const auto &gpu : std::as_const(m_gpus)) {

View file

@ -398,12 +398,11 @@ DrmPipeline *DrmOutput::pipeline() const
return m_pipeline;
}
bool DrmOutput::queueChanges(const OutputConfiguration &config)
bool DrmOutput::queueChanges(const std::shared_ptr<OutputChangeSet> &props)
{
static bool valid;
static int envOnlySoftwareRotations = qEnvironmentVariableIntValue("KWIN_DRM_SW_ROTATIONS_ONLY", &valid) == 1 || !valid;
const auto props = config.constChangeSet(this);
const auto mode = props->mode.value_or(currentMode()).lock();
if (!mode) {
return false;
@ -419,7 +418,7 @@ bool DrmOutput::queueChanges(const OutputConfiguration &config)
return true;
}
void DrmOutput::applyQueuedChanges(const OutputConfiguration &config)
void DrmOutput::applyQueuedChanges(const std::shared_ptr<OutputChangeSet> &props)
{
if (!m_connector->isConnected()) {
return;
@ -427,8 +426,6 @@ void DrmOutput::applyQueuedChanges(const OutputConfiguration &config)
Q_EMIT aboutToChange();
m_pipeline->applyPendingChanges();
auto props = config.constChangeSet(this);
State next = m_state;
next.enabled = props->enabled && m_pipeline->crtc();
next.position = props->pos.value_or(m_state.position);

View file

@ -29,6 +29,7 @@ class DrmGpu;
class DrmPipeline;
class DumbSwapchain;
class DrmLease;
class OutputChangeSet;
class KWIN_EXPORT DrmOutput : public DrmAbstractOutput
{
@ -44,8 +45,8 @@ public:
DrmOutputLayer *primaryLayer() const override;
DrmOutputLayer *cursorLayer() const override;
bool queueChanges(const OutputConfiguration &config);
void applyQueuedChanges(const OutputConfiguration &config);
bool queueChanges(const std::shared_ptr<OutputChangeSet> &properties);
void applyQueuedChanges(const std::shared_ptr<OutputChangeSet> &properties);
void revertQueuedChanges();
void updateModes();
void updateDpmsMode(DpmsMode dpmsMode);