From c050716a3b641dc7855d38cf1f97178ad5783a50 Mon Sep 17 00:00:00 2001 From: Xaver Hugl Date: Mon, 11 Jul 2022 17:07:27 +0200 Subject: [PATCH] wayland/drmlease: correct DrmLeaseDeviceV1Interface::setDrmMaster --- src/wayland/drmleasedevice_v1_interface.cpp | 24 ++++++++++++--------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/src/wayland/drmleasedevice_v1_interface.cpp b/src/wayland/drmleasedevice_v1_interface.cpp index fba61910c2..af7c5859b6 100644 --- a/src/wayland/drmleasedevice_v1_interface.cpp +++ b/src/wayland/drmleasedevice_v1_interface.cpp @@ -30,16 +30,10 @@ DrmLeaseDeviceV1Interface::~DrmLeaseDeviceV1Interface() void DrmLeaseDeviceV1Interface::setDrmMaster(bool hasDrmMaster) { - if (hasDrmMaster && !d->hasDrmMaster) { - // withdraw all connectors - for (const auto &connector : qAsConst(d->connectors)) { - DrmLeaseConnectorV1InterfacePrivate::get(connector)->withdraw(); - } - // and revoke all leases - for (const auto &lease : qAsConst(d->leases)) { - lease->deny(); - } - } else if (!hasDrmMaster && d->hasDrmMaster) { + if (hasDrmMaster == d->hasDrmMaster) { + return; + } + if (hasDrmMaster) { // send pending drm fds while (!d->pendingFds.isEmpty()) { int fd = d->createNonMasterFd(); @@ -56,8 +50,18 @@ void DrmLeaseDeviceV1Interface::setDrmMaster(bool hasDrmMaster) connectorPrivate->send(connectorResource->handle); } } + } else { + // withdraw all connectors + for (const auto &connector : qAsConst(d->connectors)) { + DrmLeaseConnectorV1InterfacePrivate::get(connector)->withdraw(); + } + // and revoke all leases + for (const auto &lease : qAsConst(d->leases)) { + lease->deny(); + } } d->hasDrmMaster = hasDrmMaster; + done(); } void DrmLeaseDeviceV1Interface::done()