diff --git a/desktop-shell/shell.c b/desktop-shell/shell.c index 0609b86d..9957e016 100644 --- a/desktop-shell/shell.c +++ b/desktop-shell/shell.c @@ -101,6 +101,7 @@ struct shell_surface { struct weston_desktop_surface *desktop_surface; struct weston_view *view; + struct weston_surface *wsurface_anim_fade; int32_t last_width, last_height; struct desktop_shell *shell; @@ -263,8 +264,8 @@ desktop_shell_destroy_surface(struct shell_surface *shsurf) wl_list_remove(&shsurf->children_link); wl_signal_emit(&shsurf->destroy_signal, shsurf); + weston_surface_unref(shsurf->wsurface_anim_fade); - weston_view_destroy(shsurf->view); if (shsurf->output_destroy_listener.notify) { wl_list_remove(&shsurf->output_destroy_listener.link); shsurf->output_destroy_listener.notify = NULL; @@ -2351,8 +2352,6 @@ desktop_surface_removed(struct weston_desktop_surface *desktop_surface, weston_fade_run(shsurf->view, 1.0, 0.0, 300.0, fade_out_done, shsurf); return; - } else { - weston_surface_unref(surface); } } @@ -2475,8 +2474,11 @@ desktop_surface_committed(struct weston_desktop_surface *desktop_surface, if (!weston_surface_is_mapped(surface)) { map(shell, shsurf, sx, sy); surface->is_mapped = true; + /* as we need to survive the weston_surface destruction we'll + * need to take another reference */ if (shsurf->shell->win_close_animation_type == ANIMATION_FADE) - ++surface->ref_count; + shsurf->wsurface_anim_fade = + weston_surface_ref(surface); return; } diff --git a/include/libweston/libweston.h b/include/libweston/libweston.h index c695c250..18677c19 100644 --- a/include/libweston/libweston.h +++ b/include/libweston/libweston.h @@ -2029,6 +2029,9 @@ struct weston_view_animation * weston_slide_run(struct weston_view *view, float start, float stop, weston_view_animation_done_func_t done, void *data); +struct weston_surface * +weston_surface_ref(struct weston_surface *surface); + void weston_surface_unref(struct weston_surface *surface); diff --git a/libweston/compositor.c b/libweston/compositor.c index fe92a462..b45f7f05 100644 --- a/libweston/compositor.c +++ b/libweston/compositor.c @@ -2295,6 +2295,16 @@ weston_view_destroy(struct weston_view *view) free(view); } +WL_EXPORT struct weston_surface * +weston_surface_ref(struct weston_surface *surface) +{ + assert(surface->ref_count < INT32_MAX && + surface->ref_count > 0); + + surface->ref_count++; + return surface; +} + WL_EXPORT void weston_surface_unref(struct weston_surface *surface) {