Commit 67521b97 authored by David Edmundson's avatar David Edmundson
Browse files

Validate surface is valid when sending TextInput leave event

It's possible for the surface to be unbound when we send the leave
event; we've called Resource::unbind() of Surface, so the Surface has,
deleteLater called, but it's still a valid object, and the first check

We get in this situation because when a surface is destroyed, we're
handling text input from the same source event.

Sending a nullpointer is a protocol error, and wayland kindly closes the

This fixes my constant:
"Did the Wayland server die" error messages when running clients.

Test Plan:
Got errors after setting up qt virtual keyboard.
Had reproducible case.
Restarted kwin after this patch, now doesn't crash.

Reviewers: #plasma, graesslin

Subscribers: apol, graesslin, plasma-devel, #frameworks

Tags: #plasma_on_wayland, #frameworks

Differential Revision:
parent 6df5c873
......@@ -306,6 +306,21 @@ void TextInputTest::testEnterLeave()
QCOMPARE(textInputChangedSpy.count(), 3);
// should still be the same text input
QCOMPARE(m_seatInterface->focusedTextInput(), serverTextInput);
//trigger an enter again and leave, but this
//time we try sending an event after the surface is unbound
//but not yet destroyed. It should work without errors
connect(serverSurface, &Resource::unbound, [=]() {
//delete the client and wait for the server to catch up
QSignalSpy unboundSpy(serverSurface, &QObject::destroyed);
void TextInputTest::testShowHidePanel_data()
......@@ -96,7 +96,7 @@ void TextInputUnstableV2Interface::Private::requestDeactivate(SeatInterface *sea
void TextInputUnstableV2Interface::Private::sendEnter(SurfaceInterface *surface, quint32 serial)
if (!resource) {
if (!resource || !surface || !surface->resource()) {
zwp_text_input_v2_send_enter(resource, serial, surface->resource());
......@@ -104,7 +104,7 @@ void TextInputUnstableV2Interface::Private::sendEnter(SurfaceInterface *surface,
void TextInputUnstableV2Interface::Private::sendLeave(quint32 serial, SurfaceInterface *surface)
if (!resource || !surface) {
if (!resource || !surface || !surface->resource()) {
zwp_text_input_v2_send_leave(resource, serial, surface->resource());
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment