From a21cb22f8b12ea73937e7e6eda8465f1cba02b6e Mon Sep 17 00:00:00 2001 From: Hans Goudey Date: Fri, 3 Jul 2020 11:58:43 -0400 Subject: 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. --- source/blender/shader_fx/intern/FX_ui_common.c | 24 ++++++------------------ 1 file changed, 6 insertions(+), 18 deletions(-) (limited to 'source/blender/shader_fx/intern') diff --git a/source/blender/shader_fx/intern/FX_ui_common.c b/source/blender/shader_fx/intern/FX_ui_common.c index e7dee920d3c..952a6df560b 100644 --- a/source/blender/shader_fx/intern/FX_ui_common.c +++ b/source/blender/shader_fx/intern/FX_ui_common.c @@ -32,7 +32,6 @@ #include "DNA_scene_types.h" #include "DNA_screen_types.h" #include "DNA_shader_fx_types.h" -#include "DNA_space_types.h" #include "ED_object.h" @@ -48,17 +47,6 @@ #include "FX_ui_common.h" /* Self include */ -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; - } - else { - return CTX_data_active_object(C); - } -} - /* -------------------------------------------------------------------- */ /** \name Panel Drag and Drop, Expansion Saving * \{ */ @@ -68,7 +56,7 @@ static Object *get_context_object(const bContext *C) */ static void shaderfx_reorder(bContext *C, Panel *panel, int new_index) { - Object *ob = get_context_object(C); + Object *ob = ED_object_active_context(C); ShaderFxData *fx = BLI_findlink(&ob->shader_fx, panel->runtime.list_index); PointerRNA props_ptr; @@ -85,7 +73,7 @@ static void shaderfx_reorder(bContext *C, Panel *panel, int new_index) */ static short get_shaderfx_expand_flag(const bContext *C, Panel *panel) { - Object *ob = get_context_object(C); + Object *ob = ED_object_active_context(C); ShaderFxData *fx = BLI_findlink(&ob->shader_fx, panel->runtime.list_index); return fx->ui_expand_flag; } @@ -95,7 +83,7 @@ static short get_shaderfx_expand_flag(const bContext *C, Panel *panel) */ static void set_shaderfx_expand_flag(const bContext *C, Panel *panel, short expand_flag) { - Object *ob = get_context_object(C); + Object *ob = ED_object_active_context(C); ShaderFxData *fx = BLI_findlink(&ob->shader_fx, panel->runtime.list_index); fx->ui_expand_flag = expand_flag; } @@ -126,7 +114,7 @@ void shaderfx_panel_get_property_pointers(const bContext *C, PointerRNA *r_ob_ptr, PointerRNA *r_md_ptr) { - Object *ob = get_context_object(C); + Object *ob = ED_object_active_context(C); ShaderFxData *md = BLI_findlink(&ob->shader_fx, panel->runtime.list_index); RNA_pointer_create(&ob->id, &RNA_ShaderFx, md, r_md_ptr); @@ -147,7 +135,7 @@ static void shaderfx_panel_header(const bContext *C, Panel *panel) PointerRNA ptr; shaderfx_panel_get_property_pointers(C, panel, NULL, &ptr); - Object *ob = get_context_object(C); + Object *ob = ED_object_active_context(C); ShaderFxData *fx = (ShaderFxData *)ptr.data; const ShaderFxTypeInfo *fxti = BKE_shaderfx_get_info(fx->type); @@ -192,7 +180,7 @@ static void shaderfx_panel_header(const bContext *C, Panel *panel) static bool shaderfx_ui_poll(const bContext *C, PanelType *UNUSED(pt)) { - Object *ob = get_context_object(C); + Object *ob = ED_object_active_context(C); return (ob != NULL) && (ob->type == OB_GPENCIL); } -- cgit v1.2.3