diff options
Diffstat (limited to 'gdb/python/py-event.c')
-rw-r--r-- | gdb/python/py-event.c | 28 |
1 files changed, 7 insertions, 21 deletions
diff --git a/gdb/python/py-event.c b/gdb/python/py-event.c index 7905bcf..a50da1f 100644 --- a/gdb/python/py-event.c +++ b/gdb/python/py-event.c @@ -89,26 +89,24 @@ int evpy_emit_event (PyObject *event, eventregistry_object *registry) { - PyObject *callback_list_copy = NULL; Py_ssize_t i; /* Create a copy of call back list and use that for notifying listeners to avoid skipping callbacks in the case of a callback being disconnected during a notification. */ - callback_list_copy = PySequence_List (registry->callbacks); - if (!callback_list_copy) - goto fail; + gdbpy_ref callback_list_copy (PySequence_List (registry->callbacks)); + if (callback_list_copy == NULL) + return -1; - for (i = 0; i < PyList_Size (callback_list_copy); i++) + for (i = 0; i < PyList_Size (callback_list_copy.get ()); i++) { - PyObject *func = PyList_GetItem (callback_list_copy, i); - PyObject *func_result; + PyObject *func = PyList_GetItem (callback_list_copy.get (), i); if (func == NULL) - goto fail; + return -1; - func_result = PyObject_CallFunctionObjArgs (func, event, NULL); + gdbpy_ref func_result (PyObject_CallFunctionObjArgs (func, event, NULL)); if (func_result == NULL) { @@ -116,21 +114,9 @@ evpy_emit_event (PyObject *event, call all of the callbacks even if one is broken. */ gdbpy_print_stack (); } - else - { - Py_DECREF (func_result); - } } - Py_XDECREF (callback_list_copy); - Py_XDECREF (event); return 0; - - fail: - gdbpy_print_stack (); - Py_XDECREF (callback_list_copy); - Py_XDECREF (event); - return -1; } static PyGetSetDef event_object_getset[] = |