diff options
author | Hans Goudey <h.goudey@me.com> | 2020-07-03 18:58:43 +0300 |
---|---|---|
committer | Hans Goudey <h.goudey@me.com> | 2020-07-03 18:58:43 +0300 |
commit | a21cb22f8b12ea73937e7e6eda8465f1cba02b6e (patch) | |
tree | 17fa94d2e1a22f8c0ece10b4a680a39784aae981 /source/blender/editors | |
parent | 33a74941c5fd4efb6eefcaace3315d3e2b65681f (diff) |
Cleanup: Deduplicate code for finding context object
Instead of manually checking the pinned object, use the existing
ED_object_active_context function. This requires adding const
to the context in that function.
Diffstat (limited to 'source/blender/editors')
-rw-r--r-- | source/blender/editors/include/ED_object.h | 4 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_templates.c | 20 | ||||
-rw-r--r-- | source/blender/editors/object/object_edit.c | 4 |
3 files changed, 8 insertions, 20 deletions
diff --git a/source/blender/editors/include/ED_object.h b/source/blender/editors/include/ED_object.h index 10cd6980c90..a851eb735b8 100644 --- a/source/blender/editors/include/ED_object.h +++ b/source/blender/editors/include/ED_object.h @@ -58,9 +58,9 @@ struct wmWindowManager; /* object_edit.c */ /* context.object */ -struct Object *ED_object_context(struct bContext *C); +struct Object *ED_object_context(const struct bContext *C); /* context.object or context.active_object */ -struct Object *ED_object_active_context(struct bContext *C); +struct Object *ED_object_active_context(const struct bContext *C); void ED_collection_hide_menu_draw(const struct bContext *C, struct uiLayout *layout); /* object_utils.c */ diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c index 992c9e07033..f3e2eef6f31 100644 --- a/source/blender/editors/interface/interface_templates.c +++ b/source/blender/editors/interface/interface_templates.c @@ -1836,18 +1836,6 @@ void uiTemplatePathBuilder(uiLayout *layout, * Template for building the panel layout for the active object's modifiers. * \{ */ -/** - * Get the active object or the property region's pinned object. - */ -static Object *get_context_object(const bContext *C) -{ - SpaceProperties *sbuts = CTX_wm_space_properties(C); - if (sbuts != NULL && (sbuts->pinid != NULL) && GS(sbuts->pinid->name) == ID_OB) { - return (Object *)sbuts->pinid; - } - return CTX_data_active_object(C); -} - static void modifier_panel_id(void *md_link, char *r_name) { ModifierData *md = (ModifierData *)md_link; @@ -1859,7 +1847,7 @@ void uiTemplateModifiers(uiLayout *UNUSED(layout), bContext *C) ScrArea *sa = CTX_wm_area(C); ARegion *region = CTX_wm_region(C); - Object *ob = get_context_object(C); + Object *ob = ED_object_active_context(C); ListBase *modifiers = &ob->modifiers; bool panels_match = UI_panel_list_matches_data(region, modifiers, modifier_panel_id); @@ -1952,7 +1940,7 @@ static ListBase *get_constraints(const bContext *C, bool use_bone_constraints) } } else { - Object *ob = get_context_object(C); + Object *ob = ED_object_active_context(C); if (ob != NULL) { constraints = &ob->constraints; } @@ -2095,7 +2083,7 @@ void uiTemplateGpencilModifiers(uiLayout *UNUSED(layout), bContext *C) { ScrArea *sa = CTX_wm_area(C); ARegion *region = CTX_wm_region(C); - Object *ob = get_context_object(C); + Object *ob = ED_object_active_context(C); ListBase *modifiers = &ob->greasepencil_modifiers; bool panels_match = UI_panel_list_matches_data(region, modifiers, gpencil_modifier_panel_id); @@ -2183,7 +2171,7 @@ void uiTemplateShaderFx(uiLayout *UNUSED(layout), bContext *C) { ScrArea *sa = CTX_wm_area(C); ARegion *region = CTX_wm_region(C); - Object *ob = get_context_object(C); + Object *ob = ED_object_active_context(C); ListBase *shaderfx = &ob->shader_fx; bool panels_match = UI_panel_list_matches_data(region, shaderfx, shaderfx_panel_id); diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c index 0ea9d24a016..a9eb454eb04 100644 --- a/source/blender/editors/object/object_edit.c +++ b/source/blender/editors/object/object_edit.c @@ -126,14 +126,14 @@ static ListBase selected_objects_get(bContext *C); /** \name Internal Utilities * \{ */ -Object *ED_object_context(bContext *C) +Object *ED_object_context(const bContext *C) { return CTX_data_pointer_get_type(C, "object", &RNA_Object).data; } /* find the correct active object per context * note: context can be NULL when called from a enum with PROP_ENUM_NO_CONTEXT */ -Object *ED_object_active_context(bContext *C) +Object *ED_object_active_context(const bContext *C) { Object *ob = NULL; if (C) { |