examples: separate compositor_fini from run

compositor_fini destroys the display, but it is an error to destroy it
before e.g. wlr_seat that references it.
This lets us order destroy calls properly, following first-in-last-out
logic.
This commit is contained in:
Dominique Martinet 2017-08-19 09:26:25 +02:00
parent 4da976bfad
commit 5885679e33
9 changed files with 21 additions and 12 deletions

View file

@ -178,9 +178,13 @@ int main() {
break;
}
compositor_run(&compositor);
wl_display_run(compositor.display);
wlr_wl_shell_destroy(state.wl_shell);
wlr_xdg_shell_v6_destroy(state.xdg_shell);
close(state.keymap_fd);
wlr_seat_destroy(state.wl_seat);
wlr_data_device_manager_destroy(state.data_device_manager);
wlr_xdg_shell_v6_destroy(state.xdg_shell);
wlr_wl_shell_destroy(state.wl_shell);
wlr_renderer_destroy(state.renderer);
compositor_fini(&compositor);
}

View file

@ -198,10 +198,11 @@ int main(int argc, char *argv[]) {
wlr_texture_upload_pixels(state.cat_texture, WL_SHM_FORMAT_ABGR8888,
cat_tex.width, cat_tex.width, cat_tex.height, cat_tex.pixel_data);
compositor_run(&compositor);
wl_display_run(compositor.display);
wlr_texture_destroy(state.cat_texture);
wlr_renderer_destroy(state.renderer);
compositor_fini(&compositor);
wlr_output_layout_destroy(state.layout);

View file

@ -146,7 +146,8 @@ int main(int argc, char *argv[]) {
}
compositor_init(&compositor);
compositor_run(&compositor);
wl_display_run(compositor.display);
compositor_fini(&compositor);
wlr_xcursor_theme_destroy(theme);
}

View file

@ -145,10 +145,11 @@ int main(int argc, char *argv[]) {
wlr_texture_upload_pixels(state.cat_texture, WL_SHM_FORMAT_ABGR8888,
cat_tex.width, cat_tex.width, cat_tex.height, cat_tex.pixel_data);
compositor_run(&compositor);
wl_display_run(compositor.display);
wlr_texture_destroy(state.cat_texture);
wlr_renderer_destroy(state.renderer);
compositor_fini(&compositor);
example_config_destroy(state.config);
}

View file

@ -674,8 +674,7 @@ void compositor_init(struct compositor_state *state) {
}
}
void compositor_run(struct compositor_state *state) {
wl_display_run(state->display);
void compositor_fini(struct compositor_state *state) {
wlr_backend_destroy(state->backend);
wl_display_destroy(state->display);
}

View file

@ -151,6 +151,6 @@ struct compositor_state {
};
void compositor_init(struct compositor_state *state);
void compositor_run(struct compositor_state *state);
void compositor_fini(struct compositor_state *state);
#endif

View file

@ -52,5 +52,6 @@ int main() {
.output_frame_cb = handle_output_frame,
};
compositor_init(&compositor);
compositor_run(&compositor);
wl_display_run(compositor.display);
compositor_fini(&compositor);
}

View file

@ -158,7 +158,8 @@ int main(int argc, char *argv[]) {
wlr_log(L_ERROR, "Could not start compositor, OOM");
exit(EXIT_FAILURE);
}
compositor_run(&compositor);
wl_display_run(compositor.display);
wlr_renderer_destroy(state.renderer);
compositor_fini(&compositor);
}

View file

@ -120,8 +120,9 @@ int main(int argc, char *argv[]) {
wlr_texture_upload_pixels(state.cat_texture, WL_SHM_FORMAT_ARGB8888,
cat_tex.width, cat_tex.width, cat_tex.height, cat_tex.pixel_data);
compositor_run(&compositor);
wl_display_run(compositor.display);
wlr_texture_destroy(state.cat_texture);
wlr_renderer_destroy(state.renderer);
compositor_fini(&compositor);
}