hc
2025-02-14 bbb9540dc49f70f6b703d1c8d1b85fa5f602d86e
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
From be1b5f8163cfaf6f3d4c52e821d5061ec0952641 Mon Sep 17 00:00:00 2001
From: Jeffy Chen <jeffy.chen@rock-chips.com>
Date: Mon, 30 May 2022 17:42:03 +0800
Subject: [PATCH 65/65] HACK: desktop-shell: Fix crash when closing APP in idle
 
This is a backport of upstream patches:
bd831407 libweston, desktop-shell: Add a wrapper for weston_surface reference
c41cdcab desktop-shell: Migrate surface_unlink_view
ab42159b desktop-shell: Add missing weston_view_destroy()
 
Signed-off-by: Jeffy Chen <jeffy.chen@rock-chips.com>
---
 desktop-shell/shell.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)
 
diff --git a/desktop-shell/shell.c b/desktop-shell/shell.c
index 8dcd416c1..bb5d02855 100644
--- a/desktop-shell/shell.c
+++ b/desktop-shell/shell.c
@@ -105,6 +105,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;
@@ -265,10 +266,12 @@ desktop_shell_destroy_surface(struct shell_surface *shsurf)
         wl_list_init(&shsurf_child->children_link);
     }
     wl_list_remove(&shsurf->children_link);
+    weston_desktop_surface_unlink_view(shsurf->view);
+    weston_view_destroy(shsurf->view);
 
     wl_signal_emit(&shsurf->destroy_signal, shsurf);
+    weston_surface_destroy(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;
@@ -2374,7 +2377,6 @@ desktop_surface_removed(struct weston_desktop_surface *desktop_surface,
     weston_desktop_surface_set_user_data(shsurf->desktop_surface, NULL);
     shsurf->desktop_surface = NULL;
 
-    weston_desktop_surface_unlink_view(shsurf->view);
     if (weston_surface_is_mapped(surface) &&
         shsurf->shell->win_close_animation_type == ANIMATION_FADE) {
 
@@ -2386,8 +2388,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_destroy(surface);
         }
     }
 
@@ -2510,8 +2510,12 @@ desktop_surface_committed(struct weston_desktop_surface *desktop_surface,
     if (!weston_surface_is_mapped(surface)) {
         map(shell, shsurf, sx, sy);
         surface->is_mapped = true;
-        if (shsurf->shell->win_close_animation_type == ANIMATION_FADE)
+        /* 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) {
+            shsurf->wsurface_anim_fade = surface;
             ++surface->ref_count;
+        }
         return;
     }
 
-- 
2.20.1