From 3bc7123592b31535567ed1e643d2e6a73d696452 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Tue, 17 Jan 2012 16:26:59 +0000 Subject: Fix crashes when loading presets with no UI present (fix #808). git-svn-id: http://svn.drobilla.net/lad/trunk/jalv@3956 a436a847-0d15-0410-975c-d299462d15a1 --- src/jalv.c | 4 ++++ src/state.c | 16 +++++++++------- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/jalv.c b/src/jalv.c index b4bd530..c719ead 100644 --- a/src/jalv.c +++ b/src/jalv.c @@ -486,6 +486,10 @@ jalv_ui_write(SuilController controller, { Jalv* host = (Jalv*)controller; + if (!host->ui) { + return; + } + if (protocol != 0 && protocol != host->atom_prot_id) { fprintf(stderr, "UI write with unsupported protocol %d (%s)\n", protocol, symap_unmap(host->symap, protocol)); diff --git a/src/state.c b/src/state.c index 03362fb..3ef4d3d 100644 --- a/src/state.c +++ b/src/state.c @@ -140,13 +140,15 @@ set_port_value(const char* port_symbol, jalv_ui_write(jalv, port->index, sizeof(fvalue), 0, &fvalue); // Update UI - char buf[sizeof(ControlChange) + sizeof(fvalue)]; - ControlChange* ev = (ControlChange*)buf; - ev->index = port->index; - ev->protocol = 0; - ev->size = sizeof(fvalue); - *(float*)ev->body = fvalue; - jack_ringbuffer_write(jalv->plugin_events, buf, sizeof(buf)); + if (jalv->ui) { + char buf[sizeof(ControlChange) + sizeof(fvalue)]; + ControlChange* ev = (ControlChange*)buf; + ev->index = port->index; + ev->protocol = 0; + ev->size = sizeof(fvalue); + *(float*)ev->body = fvalue; + jack_ringbuffer_write(jalv->plugin_events, buf, sizeof(buf)); + } } void -- cgit v1.2.1