[PATCH weston 05/10] text-backend: handle the text backend client destroy signal

rawoul at gmail.com rawoul at gmail.com
Mon Aug 25 11:56:47 PDT 2014


From: Arnaud Vrac <avrac at freebox.fr>

Mimic what was implemented for desktop-shell in 312ea4ca, to avoid a
crash on shutdown.
---
 src/text-backend.c | 21 ++++++++++++++++++++-
 1 file changed, 20 insertions(+), 1 deletion(-)

diff --git a/src/text-backend.c b/src/text-backend.c
index 7d2a064..dfb5dde 100644
--- a/src/text-backend.c
+++ b/src/text-backend.c
@@ -95,6 +95,7 @@ struct text_backend {
 		struct wl_resource *binding;
 		struct weston_process process;
 		struct wl_client *client;
+		struct wl_listener client_destroy_listener;
 
 		unsigned deathcount;
 		uint32_t deathstamp;
@@ -882,6 +883,16 @@ handle_input_method_sigchld(struct weston_process *process, int status)
 }
 
 static void
+handle_input_method_disconnect(struct wl_listener *listener, void *data)
+{
+	struct text_backend *text_backend =
+		container_of(listener, struct text_backend,
+			     input_method.client_destroy_listener);
+
+	text_backend->input_method.client = NULL;
+}
+
+static void
 launch_input_method(struct text_backend *text_backend)
 {
 	if (text_backend->input_method.binding)
@@ -898,8 +909,16 @@ launch_input_method(struct text_backend *text_backend)
 								 text_backend->input_method.path,
 								 handle_input_method_sigchld);
 
-	if (!text_backend->input_method.client)
+	if (!text_backend->input_method.client) {
 		weston_log("not able to start %s\n", text_backend->input_method.path);
+		return;
+	}
+
+	text_backend->input_method.client_destroy_listener.notify =
+		handle_input_method_disconnect;
+
+	wl_client_add_destroy_listener(text_backend->input_method.client,
+				       &text_backend->input_method.client_destroy_listener);
 }
 
 static void
-- 
1.9.1



More information about the wayland-devel mailing list