]> sigrok.org Git - libsigrok.git/commitdiff
input/saleae: keep previous channels across cleanup() call
authorGerhard Sittig <redacted>
Wed, 26 Aug 2020 14:46:41 +0000 (16:46 +0200)
committerGerhard Sittig <redacted>
Wed, 26 Aug 2020 15:06:15 +0000 (17:06 +0200)
The previous implementation of the cleanup() routine in the saleae input
module kept user specified options, but lost the previously created list
of sigrok channels. Keep it.

Also make sure that reset() voids the previous copy after grabbing its
value. To not unexpectedly release resources which still get referenced.

This shall unbreak file-reload.

src/input/saleae.c

index d16b96c483f7050ac5532d0da8a7f73a52b3b6ea..cc954e627203fe4bec9dab7d82354ce70465b81b 100644 (file)
@@ -1067,6 +1067,7 @@ static void cleanup(struct sr_input *in)
 {
        struct context *inc;
        struct context_options save_opts;
+       GSList *save_channels;
 
        if (!in)
                return;
@@ -1084,8 +1085,10 @@ static void cleanup(struct sr_input *in)
 
        /* Clear internal state, but keep what .init() has provided. */
        save_opts = inc->options;
+       save_channels = inc->module_state.prev_channels;
        memset(inc, 0, sizeof(*inc));
        inc->options = save_opts;
+       inc->module_state.prev_channels = save_channels;
 }
 
 static int reset(struct sr_input *in)
@@ -1104,6 +1107,7 @@ static int reset(struct sr_input *in)
         */
        cleanup(in);
        in->sdi->channels = inc->module_state.prev_channels;
+       inc->module_state.prev_channels = NULL;
 
        inc->module_state.got_header = FALSE;
        inc->module_state.header_sent = FALSE;