From 3d48d99647b59a6f0461baa4456660917f1bbda6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Fri, 7 Aug 2020 12:41:06 +0200 Subject: Cleanup: Python, Clang-Tidy else-after-return fixes This addresses warnings from Clang-Tidy's `readability-else-after-return` rule in the `source/blender/python` module. No functional changes. --- source/blender/python/intern/bpy_rna_anim.c | 216 ++++++++++++++-------------- 1 file changed, 106 insertions(+), 110 deletions(-) (limited to 'source/blender/python/intern/bpy_rna_anim.c') diff --git a/source/blender/python/intern/bpy_rna_anim.c b/source/blender/python/intern/bpy_rna_anim.c index 8aba2ae8598..ae19f89c348 100644 --- a/source/blender/python/intern/bpy_rna_anim.c +++ b/source/blender/python/intern/bpy_rna_anim.c @@ -181,24 +181,24 @@ static int pyrna_struct_anim_args_parse_no_resolve(PointerRNA *ptr, *r_path_full = path; return 0; } - else { - char *path_prefix = RNA_path_from_ID_to_struct(ptr); - if (path_prefix == NULL) { - PyErr_Format(PyExc_TypeError, - "%.200s could not make path for type %s", - error_prefix, - RNA_struct_identifier(ptr->type)); - return -1; - } - if (*path == '[') { - *r_path_full = BLI_string_joinN(path_prefix, path); - } - else { - *r_path_full = BLI_string_join_by_sep_charN('.', path_prefix, path); - } - MEM_freeN(path_prefix); + char *path_prefix = RNA_path_from_ID_to_struct(ptr); + if (path_prefix == NULL) { + PyErr_Format(PyExc_TypeError, + "%.200s could not make path for type %s", + error_prefix, + RNA_struct_identifier(ptr->type)); + return -1; + } + + if (*path == '[') { + *r_path_full = BLI_string_joinN(path_prefix, path); } + else { + *r_path_full = BLI_string_join_by_sep_charN('.', path_prefix, path); + } + MEM_freeN(path_prefix); + return 0; } @@ -383,33 +383,32 @@ PyObject *pyrna_struct_keyframe_insert(BPy_StructRNA *self, PyObject *args, PyOb return PyBool_FromLong(result); } - else { - ID *id = self->ptr.owner_id; - ReportList reports; - bool result; - - BKE_reports_init(&reports, RPT_STORE); - - BLI_assert(BKE_id_is_in_global_main(id)); - result = (insert_keyframe(G_MAIN, - &reports, - id, - NULL, - group_name, - path_full, - index, - &anim_eval_context, - keytype, - NULL, - options) != 0); - MEM_freeN((void *)path_full); - if (BPy_reports_to_error(&reports, PyExc_RuntimeError, true) == -1) { - return NULL; - } - - return PyBool_FromLong(result); + ID *id = self->ptr.owner_id; + ReportList reports; + bool result; + + BKE_reports_init(&reports, RPT_STORE); + + BLI_assert(BKE_id_is_in_global_main(id)); + result = (insert_keyframe(G_MAIN, + &reports, + id, + NULL, + group_name, + path_full, + index, + &anim_eval_context, + keytype, + NULL, + options) != 0); + MEM_freeN((void *)path_full); + + if (BPy_reports_to_error(&reports, PyExc_RuntimeError, true) == -1) { + return NULL; } + + return PyBool_FromLong(result); } char pyrna_struct_keyframe_delete_doc[] = @@ -453,7 +452,7 @@ PyObject *pyrna_struct_keyframe_delete(BPy_StructRNA *self, PyObject *args, PyOb NULL) == -1) { return NULL; } - else if (self->ptr.type == &RNA_NlaStrip) { + if (self->ptr.type == &RNA_NlaStrip) { /* Handle special properties for NLA Strips, whose F-Curves are stored on the * strips themselves. These are stored separately or else the properties will * not have any effect. @@ -518,22 +517,21 @@ PyObject *pyrna_struct_keyframe_delete(BPy_StructRNA *self, PyObject *args, PyOb return PyBool_FromLong(result); } - else { - bool result; - ReportList reports; - BKE_reports_init(&reports, RPT_STORE); + bool result; + ReportList reports; - result = (delete_keyframe( - G.main, &reports, self->ptr.owner_id, NULL, path_full, index, cfra) != 0); - MEM_freeN((void *)path_full); + BKE_reports_init(&reports, RPT_STORE); - if (BPy_reports_to_error(&reports, PyExc_RuntimeError, true) == -1) { - return NULL; - } + result = (delete_keyframe(G.main, &reports, self->ptr.owner_id, NULL, path_full, index, cfra) != + 0); + MEM_freeN((void *)path_full); - return PyBool_FromLong(result); + if (BPy_reports_to_error(&reports, PyExc_RuntimeError, true) == -1) { + return NULL; } + + return PyBool_FromLong(result); } char pyrna_struct_driver_add_doc[] = @@ -563,60 +561,59 @@ PyObject *pyrna_struct_driver_add(BPy_StructRNA *self, PyObject *args) &self->ptr, "bpy_struct.driver_add():", path, &path_full, &index) == -1) { return NULL; } - else { - PyObject *ret = NULL; - ReportList reports; - int result; - BKE_reports_init(&reports, RPT_STORE); + PyObject *ret = NULL; + ReportList reports; + int result; - result = ANIM_add_driver(&reports, - (ID *)self->ptr.owner_id, - path_full, - index, - CREATEDRIVER_WITH_FMODIFIER, - DRIVER_TYPE_PYTHON); + BKE_reports_init(&reports, RPT_STORE); - if (BPy_reports_to_error(&reports, PyExc_RuntimeError, true) == -1) { - return NULL; - } + result = ANIM_add_driver(&reports, + (ID *)self->ptr.owner_id, + path_full, + index, + CREATEDRIVER_WITH_FMODIFIER, + DRIVER_TYPE_PYTHON); - if (result) { - ID *id = self->ptr.owner_id; - AnimData *adt = BKE_animdata_from_id(id); - FCurve *fcu; + if (BPy_reports_to_error(&reports, PyExc_RuntimeError, true) == -1) { + return NULL; + } - PointerRNA tptr; + if (result) { + ID *id = self->ptr.owner_id; + AnimData *adt = BKE_animdata_from_id(id); + FCurve *fcu; - if (index == -1) { /* all, use a list */ - int i = 0; - ret = PyList_New(0); - while ((fcu = BKE_fcurve_find(&adt->drivers, path_full, i++))) { - RNA_pointer_create(id, &RNA_FCurve, fcu, &tptr); - PyList_APPEND(ret, pyrna_struct_CreatePyObject(&tptr)); - } - } - else { - fcu = BKE_fcurve_find(&adt->drivers, path_full, index); + PointerRNA tptr; + + if (index == -1) { /* all, use a list */ + int i = 0; + ret = PyList_New(0); + while ((fcu = BKE_fcurve_find(&adt->drivers, path_full, i++))) { RNA_pointer_create(id, &RNA_FCurve, fcu, &tptr); - ret = pyrna_struct_CreatePyObject(&tptr); + PyList_APPEND(ret, pyrna_struct_CreatePyObject(&tptr)); } - - bContext *context = BPy_GetContext(); - WM_event_add_notifier(BPy_GetContext(), NC_ANIMATION | ND_FCURVES_ORDER, NULL); - DEG_relations_tag_update(CTX_data_main(context)); } else { - /* XXX, should be handled by reports, */ - PyErr_SetString(PyExc_TypeError, - "bpy_struct.driver_add(): failed because of an internal error"); - return NULL; + fcu = BKE_fcurve_find(&adt->drivers, path_full, index); + RNA_pointer_create(id, &RNA_FCurve, fcu, &tptr); + ret = pyrna_struct_CreatePyObject(&tptr); } - MEM_freeN((void *)path_full); - - return ret; + bContext *context = BPy_GetContext(); + WM_event_add_notifier(BPy_GetContext(), NC_ANIMATION | ND_FCURVES_ORDER, NULL); + DEG_relations_tag_update(CTX_data_main(context)); } + else { + /* XXX, should be handled by reports, */ + PyErr_SetString(PyExc_TypeError, + "bpy_struct.driver_add(): failed because of an internal error"); + return NULL; + } + + MEM_freeN((void *)path_full); + + return ret; } char pyrna_struct_driver_remove_doc[] = @@ -646,26 +643,25 @@ PyObject *pyrna_struct_driver_remove(BPy_StructRNA *self, PyObject *args) &self->ptr, "bpy_struct.driver_remove():", path, &path_full, &index) == -1) { return NULL; } - else { - short result; - ReportList reports; - BKE_reports_init(&reports, RPT_STORE); + short result; + ReportList reports; - result = ANIM_remove_driver(&reports, (ID *)self->ptr.owner_id, path_full, index, 0); + BKE_reports_init(&reports, RPT_STORE); - if (path != path_full) { - MEM_freeN((void *)path_full); - } + result = ANIM_remove_driver(&reports, (ID *)self->ptr.owner_id, path_full, index, 0); - if (BPy_reports_to_error(&reports, PyExc_RuntimeError, true) == -1) { - return NULL; - } - - bContext *context = BPy_GetContext(); - WM_event_add_notifier(context, NC_ANIMATION | ND_FCURVES_ORDER, NULL); - DEG_relations_tag_update(CTX_data_main(context)); + if (path != path_full) { + MEM_freeN((void *)path_full); + } - return PyBool_FromLong(result); + if (BPy_reports_to_error(&reports, PyExc_RuntimeError, true) == -1) { + return NULL; } + + bContext *context = BPy_GetContext(); + WM_event_add_notifier(context, NC_ANIMATION | ND_FCURVES_ORDER, NULL); + DEG_relations_tag_update(CTX_data_main(context)); + + return PyBool_FromLong(result); } -- cgit v1.2.3