X-Git-Url: https://sigrok.org/gitweb/?p=libsigrokdecode.git;a=blobdiff_plain;f=controller.c;h=4d8357d48f7b9c7ab683fd579cc571e3c73611bd;hp=c6347c0a93b3d7f826ce1172a1d6413d6ec381a9;hb=8a01468302ed915f6efd6933836c27e60a019100;hpb=32cfb920625182c03eb4a4564ffdfa9d2b08f15c diff --git a/controller.c b/controller.c index c6347c0..4d8357d 100644 --- a/controller.c +++ b/controller.c @@ -326,8 +326,18 @@ SRD_API int srd_inst_option_set(struct srd_decoder_inst *di, /* All of these are synthesized objects, so they're good. */ py_dec_optkeys = PyDict_Keys(py_dec_options); num_optkeys = PyList_Size(py_dec_optkeys); + + /* + * The 'options' dictionary is a class variable, but we need to + * change it. Changing it directly will affect the entire class, + * so we need to create a new object for it, and populate that + * instead. + */ if (!(py_di_options = PyObject_GetAttrString(di->py_inst, "options"))) goto err_out; + Py_DECREF(py_di_options); + py_di_options = PyDict_New(); + PyObject_SetAttrString(di->py_inst, "options", py_di_options); for (i = 0; i < num_optkeys; i++) { /* Get the default class value for this option. */ py_str_as_str(PyList_GetItem(py_dec_optkeys, i), &key); @@ -407,13 +417,14 @@ SRD_API int srd_inst_option_set(struct srd_decoder_inst *di, ret = SRD_OK; err_out: - Py_XDECREF(py_optlist); Py_XDECREF(py_di_options); Py_XDECREF(py_dec_optkeys); Py_XDECREF(py_dec_options); g_free(key); - if (PyErr_Occurred()) + if (PyErr_Occurred()) { srd_exception_catch("Stray exception in srd_inst_option_set()."); + ret = SRD_ERR_PYTHON; + } return ret; } @@ -530,7 +541,7 @@ SRD_API int srd_inst_probe_set_all(struct srd_decoder_inst *di, * @return Pointer to a newly allocated struct srd_decoder_inst, or * NULL in case of failure. * - * @since 0.1.0 + * @since 0.1.0 (the API changed in 0.3.0, though) */ SRD_API struct srd_decoder_inst *srd_inst_new(struct srd_session *sess, const char *decoder_id, GHashTable *options) @@ -614,7 +625,7 @@ SRD_API struct srd_decoder_inst *srd_inst_new(struct srd_session *sess, * * @return SRD_OK upon success, a (negative) error code otherwise. * - * @since 0.1.0 + * @since 0.1.0 (the API changed in 0.3.0, though) */ SRD_API int srd_inst_stack(struct srd_session *sess, struct srd_decoder_inst *di_from, struct srd_decoder_inst *di_to) @@ -652,7 +663,7 @@ SRD_API int srd_inst_stack(struct srd_session *sess, * * @return Pointer to struct srd_decoder_inst, or NULL if not found. * - * @since 0.1.0 + * @since 0.1.0 (the API changed in 0.3.0, though) */ SRD_API struct srd_decoder_inst *srd_inst_find_by_id(struct srd_session *sess, const char *inst_id) @@ -913,8 +924,8 @@ static int session_is_valid(struct srd_session *sess) * A session holds all decoder instances, their stack relationships and * output callbacks. * - * @param sess. A pointer which will hold a pointer to a newly - * initialized session on return. + * @param sess A pointer which will hold a pointer to a newly + * initialized session on return. * * @return SRD_OK upon success, a (negative) error code otherwise. * @@ -952,7 +963,7 @@ SRD_API int srd_session_new(struct srd_session **sess) * * @return SRD_OK upon success, a (negative) error code otherwise. * - * @since 0.1.0 + * @since 0.1.0 (the API changed in 0.3.0, though) */ SRD_API int srd_session_start(struct srd_session *sess) { @@ -981,7 +992,7 @@ SRD_API int srd_session_start(struct srd_session *sess) ret = SRD_OK; srd_dbg("Calling start() on all instances in session %d with " - "%d probes, unitsize %d samplerate %d.", sess->session_id, + "%d probes, unitsize %d, samplerate %d.", sess->session_id, sess->num_probes, sess->unitsize, sess->samplerate); /* @@ -1093,11 +1104,11 @@ SRD_API int srd_session_send(struct srd_session *sess, uint64_t start_samplenum, * * All decoder instances and output callbacks are properly released. * - * @param sess. The session to be destroyed. + * @param sess The session to be destroyed. * * @return SRD_OK upon success, a (negative) error code otherwise. * - * @since 0.1.0 + * @since 0.3.0 */ SRD_API int srd_session_destroy(struct srd_session *sess) { @@ -1129,7 +1140,7 @@ SRD_API int srd_session_destroy(struct srd_session *sess) * @param cb The function to call. Must not be NULL. * @param cb_data Private data for the callback function. Can be NULL. * - * @since 0.1.0 + * @since 0.1.0 (the API changed in 0.3.0, though) */ SRD_API int srd_pd_output_callback_add(struct srd_session *sess, int output_type, srd_pd_output_callback_t cb, void *cb_data)