X-Git-Url: https://git.gag.com/?p=fw%2Faltos;a=blobdiff_plain;f=aoview%2Faoview_serial.c;h=29038b79af6ea747af0da5bd222ed33acb5275ea;hp=1721a28671d8a01ab7cd2d66cbd98be719cdf85b;hb=5195fcfe239e430e1f9f11774c9a245c7b29dae9;hpb=2c780d67b8a22d75a2da4b2af21fd35f0c6f5236 diff --git a/aoview/aoview_serial.c b/aoview/aoview_serial.c index 1721a286..29038b79 100644 --- a/aoview/aoview_serial.c +++ b/aoview/aoview_serial.c @@ -234,7 +234,7 @@ aoview_serial_open(const char *tty) aoview_buf_init(&serial->out_buf); serial->fd = open (tty, O_RDWR | O_NONBLOCK); if (serial->fd < 0) { - free (serial); + g_source_destroy(&serial->source); return NULL; } tcgetattr(serial->fd, &termios); @@ -250,6 +250,7 @@ aoview_serial_open(const char *tty) serial->poll_fd.events = G_IO_IN | G_IO_OUT | G_IO_HUP | G_IO_ERR; g_source_attach(&serial->source, NULL); g_source_add_poll(&serial->source,&serial->poll_fd); + aoview_serial_set_callback(serial, NULL); return serial; } @@ -257,15 +258,13 @@ void aoview_serial_close(struct aoview_serial *serial) { g_source_remove_poll(&serial->source, &serial->poll_fd); + close(serial->fd); g_source_destroy(&serial->source); - g_source_unref(&serial->source); } void aoview_serial_set_callback(struct aoview_serial *serial, - aoview_serial_callback func, - gpointer data, - GDestroyNotify notify) + aoview_serial_callback func) { - g_source_set_callback(&serial->source, (GSourceFunc) func, data, notify); + g_source_set_callback(&serial->source, (GSourceFunc) func, serial, NULL); }