text: Set context->model to NULL when we deactivate text input

There's a small window between the input method (eg the on-sreen keyboard)
receiving the deactivate and destroying the context, where the keyboard may
send requests, which we forward to the destroyed input method.  Fix this
by setting the contexts model to NULL right away and then avoid sending
events if context->model is NULL.

Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=69490
dev
Kristian Høgsberg 11 years ago
parent 211b517e8c
commit c180977e7c
  1. 39
      src/text-backend.c

@ -121,6 +121,7 @@ deactivate_text_input(struct text_input *text_input,
input_method_context_end_keyboard_grab(input_method->context); input_method_context_end_keyboard_grab(input_method->context);
wl_input_method_send_deactivate(input_method->input_method_binding, wl_input_method_send_deactivate(input_method->input_method_binding,
input_method->context->resource); input_method->context->resource);
input_method->context->model = NULL;
} }
wl_list_remove(&input_method->link); wl_list_remove(&input_method->link);
@ -437,7 +438,9 @@ input_method_context_commit_string(struct wl_client *client,
struct input_method_context *context = struct input_method_context *context =
wl_resource_get_user_data(resource); wl_resource_get_user_data(resource);
wl_text_input_send_commit_string(context->model->resource, serial, text); if (context->model)
wl_text_input_send_commit_string(context->model->resource,
serial, text);
} }
static void static void
@ -450,7 +453,9 @@ input_method_context_preedit_string(struct wl_client *client,
struct input_method_context *context = struct input_method_context *context =
wl_resource_get_user_data(resource); wl_resource_get_user_data(resource);
wl_text_input_send_preedit_string(context->model->resource, serial, text, commit); if (context->model)
wl_text_input_send_preedit_string(context->model->resource,
serial, text, commit);
} }
static void static void
@ -463,7 +468,9 @@ input_method_context_preedit_styling(struct wl_client *client,
struct input_method_context *context = struct input_method_context *context =
wl_resource_get_user_data(resource); wl_resource_get_user_data(resource);
wl_text_input_send_preedit_styling(context->model->resource, index, length, style); if (context->model)
wl_text_input_send_preedit_styling(context->model->resource,
index, length, style);
} }
static void static void
@ -474,7 +481,9 @@ input_method_context_preedit_cursor(struct wl_client *client,
struct input_method_context *context = struct input_method_context *context =
wl_resource_get_user_data(resource); wl_resource_get_user_data(resource);
wl_text_input_send_preedit_cursor(context->model->resource, cursor); if (context->model)
wl_text_input_send_preedit_cursor(context->model->resource,
cursor);
} }
static void static void
@ -486,7 +495,9 @@ input_method_context_delete_surrounding_text(struct wl_client *client,
struct input_method_context *context = struct input_method_context *context =
wl_resource_get_user_data(resource); wl_resource_get_user_data(resource);
wl_text_input_send_delete_surrounding_text(context->model->resource, index, length); if (context->model)
wl_text_input_send_delete_surrounding_text(context->model->resource,
index, length);
} }
static void static void
@ -498,7 +509,9 @@ input_method_context_cursor_position(struct wl_client *client,
struct input_method_context *context = struct input_method_context *context =
wl_resource_get_user_data(resource); wl_resource_get_user_data(resource);
wl_text_input_send_cursor_position(context->model->resource, index, anchor); if (context->model)
wl_text_input_send_cursor_position(context->model->resource,
index, anchor);
} }
static void static void
@ -509,6 +522,7 @@ input_method_context_modifiers_map(struct wl_client *client,
struct input_method_context *context = struct input_method_context *context =
wl_resource_get_user_data(resource); wl_resource_get_user_data(resource);
if (context->model)
wl_text_input_send_modifiers_map(context->model->resource, map); wl_text_input_send_modifiers_map(context->model->resource, map);
} }
@ -524,8 +538,9 @@ input_method_context_keysym(struct wl_client *client,
struct input_method_context *context = struct input_method_context *context =
wl_resource_get_user_data(resource); wl_resource_get_user_data(resource);
wl_text_input_send_keysym(context->model->resource, serial, time, if (context->model)
sym, state, modifiers); wl_text_input_send_keysym(context->model->resource,
serial, time, sym, state, modifiers);
} }
static void static void
@ -653,7 +668,9 @@ input_method_context_language(struct wl_client *client,
{ {
struct input_method_context *context = wl_resource_get_user_data(resource); struct input_method_context *context = wl_resource_get_user_data(resource);
wl_text_input_send_language(context->model->resource, serial, language); if (context->model)
wl_text_input_send_language(context->model->resource,
serial, language);
} }
static void static void
@ -664,7 +681,9 @@ input_method_context_text_direction(struct wl_client *client,
{ {
struct input_method_context *context = wl_resource_get_user_data(resource); struct input_method_context *context = wl_resource_get_user_data(resource);
wl_text_input_send_text_direction(context->model->resource, serial, direction); if (context->model)
wl_text_input_send_text_direction(context->model->resource,
serial, direction);
} }

Loading…
Cancel
Save