Fix memory leak in wlr_cursor

This commit is contained in:
emersion 2017-10-31 14:58:58 +01:00
parent 2c63aa2056
commit 7dc716a2bb
No known key found for this signature in database
GPG key ID: 0FDE7BE0E88F5E48
2 changed files with 13 additions and 12 deletions

View file

@ -212,6 +212,11 @@ int main(int argc, char *argv[]) {
wl_display_run(compositor.display);
compositor_fini(&compositor);
struct sample_cursor *cursor;
wl_list_for_each(cursor, &state.cursors, link) {
// TODO
}
wlr_xcursor_theme_destroy(theme);
example_config_destroy(state.config);
wlr_output_layout_destroy(state.layout);

View file

@ -98,7 +98,7 @@ struct wlr_cursor *wlr_cursor_create() {
return cur;
}
static void output_cursor_remove(
static void output_cursor_destroy(
struct wlr_cursor_output_cursor *output_cursor) {
wl_list_remove(&output_cursor->layout_output_destroy.link);
wl_list_remove(&output_cursor->link);
@ -111,15 +111,10 @@ static void wlr_cursor_detach_output_layout(struct wlr_cursor *cur) {
return;
}
struct wlr_output_layout_output *l_output;
wl_list_for_each(l_output, &cur->state->layout->outputs, link) {
struct wlr_cursor_output_cursor *output_cursor, *tmp;
wl_list_for_each_safe(output_cursor, tmp, &cur->state->output_cursors,
link) {
if (output_cursor->output_cursor->output == l_output->output) {
output_cursor_remove(output_cursor);
}
}
struct wlr_cursor_output_cursor *output_cursor, *tmp;
wl_list_for_each_safe(output_cursor, tmp, &cur->state->output_cursors,
link) {
output_cursor_destroy(output_cursor);
}
wl_list_remove(&cur->state->layout_destroy.link);
@ -161,6 +156,7 @@ void wlr_cursor_destroy(struct wlr_cursor *cur) {
wlr_cursor_device_destroy(device);
}
free(cur->state);
free(cur);
}
@ -518,7 +514,7 @@ static void handle_layout_output_destroy(struct wl_listener *listener,
struct wlr_cursor_output_cursor *output_cursor =
wl_container_of(listener, output_cursor, layout_output_destroy);
//struct wlr_output_layout_output *l_output = data;
output_cursor_remove(output_cursor);
output_cursor_destroy(output_cursor);
}
static void layout_add(struct wlr_cursor_state *state,
@ -542,7 +538,7 @@ static void layout_add(struct wlr_cursor_state *state,
wl_signal_add(&l_output->events.destroy,
&output_cursor->layout_output_destroy);
wl_list_insert(&state->cursor->state->output_cursors, &output_cursor->link);
wl_list_insert(&state->output_cursors, &output_cursor->link);
}
static void handle_layout_add(struct wl_listener *listener, void *data) {