From 2f1ecfeda32ef1adb8ea8077b7c134bff47e7612 Mon Sep 17 00:00:00 2001 From: Chase Douglas Date: Wed, 23 Nov 2011 11:15:30 -0800 Subject: Check for a found touch before attempting to paint it Signed-off-by: Chase Douglas --- multitouch.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/multitouch.c b/multitouch.c index 53c52de..817de22 100644 --- a/multitouch.c +++ b/multitouch.c @@ -341,6 +341,12 @@ static void paint_touch_update(struct multitouch *mt, XIDeviceEvent *event) { struct touchpoint *t = find_touch(mt, event->detail); + if (!t) + { + error("Could not find touch in %s\n", __FUNCTION__); + return; + } + cairo_save(mt->cr); cairo_set_source_rgba(mt->cr, 0, 0, 0, t->owned ? 1 : .5); cairo_move_to(mt->cr, t->x, t->y); @@ -359,6 +365,12 @@ static void paint_touch_end(struct multitouch *mt, XIDeviceEvent *event) int rsize = 30; struct touchpoint *t = find_touch(mt, event->detail); + if (!t) + { + error("Could not find touch in %s\n", __FUNCTION__); + return; + } + t->x = event->event_x; t->y = event->event_y; t->state = TSTATE_END; -- cgit v1.2.3