From e2c1e172b28fed82059b3c73b5b53e591b68a599 Mon Sep 17 00:00:00 2001 From: Thomas White Date: Thu, 1 Jul 2021 18:35:54 +0200 Subject: Fixture display: Fix shutdown logic --- src/repl-connection.c | 10 +++++++++- src/starlet-fixture-display.c | 19 ++++++++----------- 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/src/repl-connection.c b/src/repl-connection.c index 663c649..2e3201f 100644 --- a/src/repl-connection.c +++ b/src/repl-connection.c @@ -212,10 +212,18 @@ ReplConnection *repl_connection_new(const char *socket, int repl_send(ReplConnection *repl, const char *line) { GError *error = NULL; - GOutputStream *out = g_io_stream_get_output_stream(G_IO_STREAM(repl->conn)); + GOutputStream *out; + + if ( repl->conn == NULL ) { + fprintf(stderr, "No REPL to send to!\n"); + return 1; + } + if ( repl->verbose ) { printf("%p send: %s\n", repl, line); } + + out = g_io_stream_get_output_stream(G_IO_STREAM(repl->conn)); if ( g_output_stream_write(out, line, strlen(line), NULL, &error) == -1 ) { fprintf(stderr, "Couldn't send: %s\n", error->message); return 1; diff --git a/src/starlet-fixture-display.c b/src/starlet-fixture-display.c index 96ed4fb..cba3497 100644 --- a/src/starlet-fixture-display.c +++ b/src/starlet-fixture-display.c @@ -254,20 +254,17 @@ static gint realise_sig(GtkWidget *da, struct fixture_display *fixd) static gboolean redraw_cb(gpointer data) { struct fixture_display *fixd = data; - if ( !fixd->shutdown ) { - request_intensities(fixd); - request_selection(fixd); - redraw(fixd); - return G_SOURCE_CONTINUE; + if ( repl_closed(fixd->repl) ) { + gtk_main_quit(); + return G_SOURCE_REMOVE; } else { - if ( repl_closed(fixd->repl) ) { - gtk_main_quit(); - return G_SOURCE_REMOVE; - } else { - return G_SOURCE_CONTINUE; + if ( !fixd->shutdown ) { + request_intensities(fixd); + request_selection(fixd); + redraw(fixd); } + return G_SOURCE_CONTINUE; } - } -- cgit v1.2.3