wayland: Prevent sending xdg_output properties if wl_output is removed

If the wl_output has been removed, kwin can crash all Qt clients by
sending a wl_output.done event. Also, it makes no sense to send output
events after the corresponding output has been removed.

CCBUG: 451028
This commit is contained in:
Vlad Zahorodnii 2022-08-30 12:56:23 +03:00
parent 4fe0bda4db
commit d6706c5ce4
3 changed files with 14 additions and 6 deletions

View file

@ -184,6 +184,11 @@ KWin::Output *OutputInterface::handle() const
return d->handle;
}
bool OutputInterface::isRemoved() const
{
return d->isGlobalRemoved();
}
void OutputInterface::remove()
{
if (d->isGlobalRemoved()) {

View file

@ -51,6 +51,7 @@ public:
explicit OutputInterface(Display *display, KWin::Output *handle, QObject *parent = nullptr);
~OutputInterface() override;
bool isRemoved() const;
void remove();
KWin::Output *handle() const;

View file

@ -195,6 +195,10 @@ void XdgOutputV1InterfacePrivate::zxdg_output_v1_destroy(Resource *resource)
void XdgOutputV1InterfacePrivate::zxdg_output_v1_bind_resource(Resource *resource)
{
if (!output || output->isRemoved()) {
return;
}
sendLogicalPosition(resource, pos);
sendLogicalSize(resource, size);
if (resource->version() >= ZXDG_OUTPUT_V1_NAME_SINCE_VERSION) {
@ -212,7 +216,7 @@ void XdgOutputV1InterfacePrivate::zxdg_output_v1_bind_resource(Resource *resourc
void XdgOutputV1InterfacePrivate::sendLogicalSize(Resource *resource, const QSize &size)
{
if (!output) {
if (!output || output->isRemoved()) {
return;
}
ClientConnection *connection = output->display()->getConnection(resource->client());
@ -223,7 +227,7 @@ void XdgOutputV1InterfacePrivate::sendLogicalSize(Resource *resource, const QSiz
void XdgOutputV1InterfacePrivate::sendLogicalPosition(Resource *resource, const QPoint &pos)
{
if (!output) {
if (!output || output->isRemoved()) {
return;
}
ClientConnection *connection = output->display()->getConnection(resource->client());
@ -234,14 +238,12 @@ void XdgOutputV1InterfacePrivate::sendLogicalPosition(Resource *resource, const
void XdgOutputV1InterfacePrivate::sendDone(Resource *resource)
{
if (!doneOnce) {
if (!doneOnce || !output || output->isRemoved()) {
return;
}
if (wl_resource_get_version(resource->handle) >= 3) {
if (output) {
output->done(resource->client());
}
output->done(resource->client());
} else {
send_done(resource->handle);
}