diff --git a/tools/eis-demo-server.c b/tools/eis-demo-server.c index a2b284b..b422207 100644 --- a/tools/eis-demo-server.c +++ b/tools/eis-demo-server.c @@ -741,21 +741,27 @@ int main(int argc, char **argv) switch (counter++ % 5) { case 0: - colorprint("sending touch down event\n"); touch = eis_device_touch_new(touchscreen); - eis_touch_down(touch, 100 + ++x, 200 - ++y); - eis_device_frame(touchscreen, now); - democlient->touch = touch; + if (touch) { /* NULL if client was disconnected internally already */ + colorprint("sending touch down event\n"); + eis_touch_down(touch, 100 + ++x, 200 - ++y); + eis_device_frame(touchscreen, now); + democlient->touch = touch; + } break; case 4: - colorprint("sending touch down event\n"); - eis_touch_up(touch); - eis_device_frame(touchscreen, now); - democlient->touch = eis_touch_unref(touch); + if (touch) { + colorprint("sending touch down event\n"); + eis_touch_up(touch); + eis_device_frame(touchscreen, now); + democlient->touch = eis_touch_unref(touch); + } break; default: - eis_touch_motion(touch, 100 + ++x, 200 - ++y); - eis_device_frame(touchscreen, now); + if (touch) { + eis_touch_motion(touch, 100 + ++x, 200 - ++y); + eis_device_frame(touchscreen, now); + } break; }