]> sigrok.org Git - libsigrokdecode.git/blobdiff - decoder.c
pdtest: Add option for custom sigrok-dumps repository path.
[libsigrokdecode.git] / decoder.c
index f6032f59b65830a64654a67c98a48d706b88a7bb..af988cb8b3cf93708bc26a299c22f1bb85a22dfd 100644 (file)
--- a/decoder.c
+++ b/decoder.c
@@ -260,6 +260,11 @@ SRD_API int srd_decoder_load(const char *module_name)
        if (!module_name)
                return SRD_ERR_ARG;
 
+       if (PyDict_GetItemString(PyImport_GetModuleDict(), module_name)) {
+               /* Module was already imported. */
+               return SRD_OK;
+       }
+
        srd_dbg("Loading protocol decoder '%s'.", module_name);
 
        py_basedec = py_method = py_attr = NULL;
@@ -561,13 +566,12 @@ SRD_API int srd_decoder_unload(struct srd_decoder *dec)
 SRD_API int srd_decoder_load_all(void)
 {
        GDir *dir;
-       GError *error;
        const gchar *direntry;
 
        if (!srd_check_init())
                return SRD_ERR;
 
-       if (!(dir = g_dir_open(DECODERS_DIR, 0, &error))) {
+       if (!(dir = g_dir_open(DECODERS_DIR, 0, NULL))) {
                srd_err("Unable to open %s for reading.", DECODERS_DIR);
                return SRD_ERR_DECODERS_DIR;
        }