[PATCH weston 3/5] compositor: Fix crash when surface is map'd and unmap'd before repaint
Ander Conselvan de Oliveira
ander.conselvan.de.oliveira at intel.com
Fri Jun 15 07:32:12 PDT 2012
---
For the record, I ran into this issue while doing the cursor surfaces
patches, but I could also reproduce it with this patch. I looked into
writing this as test but it wasn't obvious to me how I would do that
with the current test framework, so I just gave up.
clients/simple-shm.c | 18 +++++++++++++++++-
1 files changed, 17 insertions(+), 1 deletions(-)
diff --git a/clients/simple-shm.c b/clients/simple-shm.c
index 252e040..dc966a3 100644
--- a/clients/simple-shm.c
+++ b/clients/simple-shm.c
@@ -201,18 +201,29 @@ paint_pixels(void *image, int width, int height, uint32_t time)
}
}
+static int needs_remap;
+static uint32_t last_time;
+
static const struct wl_callback_listener frame_listener;
static void
redraw(void *data, struct wl_callback *callback, uint32_t time)
{
struct window *window = data;
+ static int count;
+
+ last_time = time;
paint_pixels(window->shm_data, window->width, window->height, time);
wl_surface_attach(window->surface, window->buffer, 0, 0);
wl_surface_damage(window->surface,
0, 0, window->width, window->height);
+ if (count++ % 20 == 19) {
+ wl_surface_attach(window->surface, NULL, 0, 0);
+ needs_remap = 1;
+ }
+
if (callback)
wl_callback_destroy(callback);
@@ -332,8 +343,13 @@ main(int argc, char **argv)
redraw(window, NULL, 0);
- while (running)
+ while (running) {
+ if (needs_remap) {
+ redraw(window, NULL, last_time);
+ needs_remap = 0;
+ }
wl_display_iterate(display->display, display->mask);
+ }
fprintf(stderr, "simple-shm exiting\n");
destroy_window(window);
--
1.7.4.1
More information about the wayland-devel
mailing list