From e299798bbf71959b372fd12c0567bad3ed8c116a Mon Sep 17 00:00:00 2001 From: Matt Ebb Date: Fri, 4 Dec 2009 06:33:01 +0000 Subject: Fix for [#20203] Linked objects - A few bugs Did a lot of cleaning Object operator poll functions to check if the object's linked or not. For this, added the function ED_operator_object_active_editable() as opposed to ED_operator_object_active() --- source/blender/editors/include/ED_screen.h | 1 + source/blender/editors/object/object_add.c | 6 +++--- source/blender/editors/object/object_constraint.c | 6 +++--- source/blender/editors/object/object_edit.c | 10 +++++++--- source/blender/editors/object/object_modifier.c | 10 ++-------- source/blender/editors/object/object_relations.c | 6 +++--- source/blender/editors/object/object_transform.c | 16 ++++++++-------- source/blender/editors/physics/particle_object.c | 5 ++++- source/blender/editors/physics/physics_fluid.c | 2 +- source/blender/editors/screen/screen_ops.c | 6 ++++++ 10 files changed, 38 insertions(+), 30 deletions(-) (limited to 'source/blender') diff --git a/source/blender/editors/include/ED_screen.h b/source/blender/editors/include/ED_screen.h index fb708e4d1c7..2f658e48557 100644 --- a/source/blender/editors/include/ED_screen.h +++ b/source/blender/editors/include/ED_screen.h @@ -132,6 +132,7 @@ int ED_operator_nla_active(struct bContext *C); int ED_operator_logic_active(struct bContext *C); int ED_operator_object_active(struct bContext *C); +int ED_operator_object_active_editable(struct bContext *C); int ED_operator_editmesh(struct bContext *C); int ED_operator_editarmature(struct bContext *C); int ED_operator_editcurve(struct bContext *C); diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c index 0ce58461268..5ad6e2d557c 100644 --- a/source/blender/editors/object/object_add.c +++ b/source/blender/editors/object/object_add.c @@ -999,7 +999,7 @@ static int convert_poll(bContext *C) Object *obact= CTX_data_active_object(C); Scene *scene= CTX_data_scene(C); - return (!scene->id.lib && obact && scene->obedit != obact && (obact->flag & SELECT)); + return (!scene->id.lib && obact && scene->obedit != obact && (obact->flag & SELECT) && !(obact->id.lib)); } static int convert_exec(bContext *C, wmOperator *op) @@ -1510,7 +1510,7 @@ static int join_poll(bContext *C) { Object *ob= CTX_data_active_object(C); - if (!ob) return 0; + if (!ob || ob->id.lib) return 0; if (ELEM4(ob->type, OB_MESH, OB_CURVE, OB_SURF, OB_ARMATURE)) return ED_operator_screenactive(C); @@ -1563,7 +1563,7 @@ static int join_shapes_poll(bContext *C) { Object *ob= CTX_data_active_object(C); - if (!ob) return 0; + if (!ob || ob->id.lib) return 0; /* only meshes supported at the moment */ if (ob->type == OB_MESH) diff --git a/source/blender/editors/object/object_constraint.c b/source/blender/editors/object/object_constraint.c index eababfe8080..19ba5f7b32b 100644 --- a/source/blender/editors/object/object_constraint.c +++ b/source/blender/editors/object/object_constraint.c @@ -885,7 +885,7 @@ void OBJECT_OT_constraints_clear(wmOperatorType *ot) /* callbacks */ ot->exec= object_constraints_clear_exec; - ot->poll= ED_operator_object_active; + ot->poll= ED_operator_object_active_editable; } /************************ add constraint operators *********************/ @@ -1212,7 +1212,7 @@ void OBJECT_OT_constraint_add(wmOperatorType *ot) /* api callbacks */ ot->invoke= WM_menu_invoke; ot->exec= object_constraint_add_exec; - ot->poll= ED_operator_object_active; + ot->poll= ED_operator_object_active_editable; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; @@ -1231,7 +1231,7 @@ void OBJECT_OT_constraint_add_with_targets(wmOperatorType *ot) /* api callbacks */ ot->invoke= WM_menu_invoke; ot->exec= object_constraint_add_exec; - ot->poll= ED_operator_object_active; + ot->poll= ED_operator_object_active_editable; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c index 4678ee35fcd..4fed6108f86 100644 --- a/source/blender/editors/object/object_edit.c +++ b/source/blender/editors/object/object_edit.c @@ -553,7 +553,7 @@ void OBJECT_OT_posemode_toggle(wmOperatorType *ot) /* api callbacks */ ot->exec= posemode_exec; - ot->poll= ED_operator_object_active; + ot->poll= ED_operator_object_active_editable; /* flag */ ot->flag= OPTYPE_REGISTER; @@ -1651,6 +1651,7 @@ void OBJECT_OT_shade_flat(wmOperatorType *ot) ot->idname= "OBJECT_OT_shade_flat"; /* api callbacks */ + ot->poll= ED_operator_object_active_editable; ot->exec= shade_smooth_exec; /* flags */ @@ -1664,8 +1665,9 @@ void OBJECT_OT_shade_smooth(wmOperatorType *ot) ot->idname= "OBJECT_OT_shade_smooth"; /* api callbacks */ + ot->poll= ED_operator_object_active_editable; ot->exec= shade_smooth_exec; - + /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; } @@ -1958,7 +1960,7 @@ void OBJECT_OT_mode_set(wmOperatorType *ot) /* api callbacks */ ot->exec= object_mode_set_exec; - ot->poll= ED_operator_object_active; + ot->poll= ED_operator_object_active_editable; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; @@ -2013,6 +2015,7 @@ void OBJECT_OT_game_property_new(wmOperatorType *ot) /* api callbacks */ ot->exec= game_property_new; + ot->poll= ED_operator_object_active_editable; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; @@ -2049,6 +2052,7 @@ void OBJECT_OT_game_property_remove(wmOperatorType *ot) /* api callbacks */ ot->exec= game_property_remove; + ot->poll= ED_operator_object_active_editable; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; diff --git a/source/blender/editors/object/object_modifier.c b/source/blender/editors/object/object_modifier.c index 88763f63f7b..0c1e6b86a99 100644 --- a/source/blender/editors/object/object_modifier.c +++ b/source/blender/editors/object/object_modifier.c @@ -542,7 +542,7 @@ void OBJECT_OT_modifier_add(wmOperatorType *ot) /* api callbacks */ ot->invoke= WM_menu_invoke; ot->exec= modifier_add_exec; - ot->poll= ED_operator_object_active; + ot->poll= ED_operator_object_active_editable; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; @@ -574,7 +574,6 @@ void OBJECT_OT_modifier_remove(wmOperatorType *ot) ot->name= "Remove Modifier"; ot->description= "Remove a modifier from the active object."; ot->idname= "OBJECT_OT_modifier_remove"; - ot->poll= ED_operator_object_active; ot->exec= modifier_remove_exec; ot->poll= modifier_poll; @@ -605,7 +604,6 @@ void OBJECT_OT_modifier_move_up(wmOperatorType *ot) ot->name= "Move Up Modifier"; ot->description= "Move modifier up in the stack."; ot->idname= "OBJECT_OT_modifier_move_up"; - ot->poll= ED_operator_object_active; ot->exec= modifier_move_up_exec; ot->poll= modifier_poll; @@ -636,7 +634,6 @@ void OBJECT_OT_modifier_move_down(wmOperatorType *ot) ot->name= "Move Down Modifier"; ot->description= "Move modifier down in the stack."; ot->idname= "OBJECT_OT_modifier_move_down"; - ot->poll= ED_operator_object_active; ot->exec= modifier_move_down_exec; ot->poll= modifier_poll; @@ -674,7 +671,6 @@ void OBJECT_OT_modifier_apply(wmOperatorType *ot) ot->name= "Apply Modifier"; ot->description= "Apply modifier and remove from the stack."; ot->idname= "OBJECT_OT_modifier_apply"; - ot->poll= ED_operator_object_active; //ot->invoke= WM_menu_invoke; ot->exec= modifier_apply_exec; @@ -709,7 +705,6 @@ void OBJECT_OT_modifier_convert(wmOperatorType *ot) ot->name= "Convert Modifier"; ot->description= "Convert particles to a mesh object."; ot->idname= "OBJECT_OT_modifier_convert"; - ot->poll= ED_operator_object_active; ot->exec= modifier_convert_exec; ot->poll= modifier_poll; @@ -740,7 +735,6 @@ void OBJECT_OT_modifier_copy(wmOperatorType *ot) ot->name= "Copy Modifier"; ot->description= "Duplicate modifier at the same position in the stack."; ot->idname= "OBJECT_OT_modifier_copy"; - ot->poll= ED_operator_object_active; ot->exec= modifier_copy_exec; ot->poll= modifier_poll; @@ -769,7 +763,7 @@ void OBJECT_OT_multires_higher_levels_delete(wmOperatorType *ot) { ot->name= "Delete Higher Levels"; ot->idname= "OBJECT_OT_multires_higher_levels_delete"; - ot->poll= ED_operator_object_active; + ot->poll= ED_operator_object_active_editable; ot->exec= multires_higher_levels_delete_exec; diff --git a/source/blender/editors/object/object_relations.c b/source/blender/editors/object/object_relations.c index 749b1e34651..b8839360296 100644 --- a/source/blender/editors/object/object_relations.c +++ b/source/blender/editors/object/object_relations.c @@ -475,7 +475,7 @@ void OBJECT_OT_parent_clear(wmOperatorType *ot) ot->invoke= WM_menu_invoke; ot->exec= parent_clear_exec; - ot->poll= ED_operator_object_active; + ot->poll= ED_operator_object_active_editable; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; @@ -733,7 +733,7 @@ void OBJECT_OT_parent_set(wmOperatorType *ot) ot->invoke= parent_set_invoke; ot->exec= parent_set_exec; - ot->poll= ED_operator_object_active; + ot->poll= ED_operator_object_active_editable; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; @@ -788,7 +788,7 @@ void OBJECT_OT_parent_no_inverse_set(wmOperatorType *ot) /* api callbacks */ ot->invoke= WM_operator_confirm; ot->exec= parent_noinv_set_exec; - ot->poll= ED_operator_object_active; + ot->poll= ED_operator_object_active_editable; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; diff --git a/source/blender/editors/object/object_transform.c b/source/blender/editors/object/object_transform.c index d990df72c0d..69a2315fd5d 100644 --- a/source/blender/editors/object/object_transform.c +++ b/source/blender/editors/object/object_transform.c @@ -119,7 +119,7 @@ void OBJECT_OT_location_clear(wmOperatorType *ot) /* api callbacks */ ot->exec= object_location_clear_exec; - ot->poll= ED_operator_object_active; + ot->poll= ED_operator_object_active_editable; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; @@ -255,7 +255,7 @@ void OBJECT_OT_rotation_clear(wmOperatorType *ot) /* api callbacks */ ot->exec= object_rotation_clear_exec; - ot->poll= ED_operator_object_active; + ot->poll= ED_operator_object_active_editable; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; @@ -313,7 +313,7 @@ void OBJECT_OT_scale_clear(wmOperatorType *ot) /* api callbacks */ ot->exec= object_scale_clear_exec; - ot->poll= ED_operator_object_active; + ot->poll= ED_operator_object_active_editable; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; @@ -357,7 +357,7 @@ void OBJECT_OT_origin_clear(wmOperatorType *ot) /* api callbacks */ ot->exec= object_origin_clear_exec; - ot->poll= ED_operator_object_active; + ot->poll= ED_operator_object_active_editable; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; @@ -579,7 +579,7 @@ void OBJECT_OT_visual_transform_apply(wmOperatorType *ot) /* api callbacks */ ot->exec= visual_transform_apply_exec; - ot->poll= ED_operator_object_active; + ot->poll= ED_operator_object_active_editable; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; @@ -599,7 +599,7 @@ void OBJECT_OT_location_apply(wmOperatorType *ot) /* api callbacks */ ot->exec= location_apply_exec; - ot->poll= ED_operator_object_active; + ot->poll= ED_operator_object_active_editable; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; @@ -619,7 +619,7 @@ void OBJECT_OT_scale_apply(wmOperatorType *ot) /* api callbacks */ ot->exec= scale_apply_exec; - ot->poll= ED_operator_object_active; + ot->poll= ED_operator_object_active_editable; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; @@ -639,7 +639,7 @@ void OBJECT_OT_rotation_apply(wmOperatorType *ot) /* api callbacks */ ot->exec= rotation_apply_exec; - ot->poll= ED_operator_object_active; + ot->poll= ED_operator_object_active_editable; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; diff --git a/source/blender/editors/physics/particle_object.c b/source/blender/editors/physics/particle_object.c index ce740a53db8..f94835593c5 100644 --- a/source/blender/editors/physics/particle_object.c +++ b/source/blender/editors/physics/particle_object.c @@ -56,6 +56,7 @@ #include "WM_types.h" #include "ED_particle.h" +#include "ED_screen.h" #include "physics_intern.h" @@ -83,8 +84,9 @@ void OBJECT_OT_particle_system_add(wmOperatorType *ot) ot->description="Add a particle system."; /* api callbacks */ + ot->poll= ED_operator_object_active_editable; ot->exec= particle_system_add_exec; - + /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; } @@ -120,6 +122,7 @@ void OBJECT_OT_particle_system_remove(wmOperatorType *ot) ot->description="Remove the selected particle system."; /* api callbacks */ + ot->poll= ED_operator_object_active_editable; ot->exec= particle_system_remove_exec; /* flags */ diff --git a/source/blender/editors/physics/physics_fluid.c b/source/blender/editors/physics/physics_fluid.c index e5d553dacc7..7893b314e3e 100644 --- a/source/blender/editors/physics/physics_fluid.c +++ b/source/blender/editors/physics/physics_fluid.c @@ -1200,6 +1200,6 @@ void FLUID_OT_bake(wmOperatorType *ot) /* api callbacks */ ot->exec= fluid_bake_exec; - ot->poll= ED_operator_object_active; + ot->poll= ED_operator_object_active_editable; } diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c index afee27cd0f3..633d5181bbf 100644 --- a/source/blender/editors/screen/screen_ops.c +++ b/source/blender/editors/screen/screen_ops.c @@ -218,6 +218,12 @@ int ED_operator_object_active(bContext *C) return NULL != CTX_data_active_object(C); } +int ED_operator_object_active_editable(bContext *C) +{ + Object *ob=CTX_data_active_object(C); + return ((ob != NULL) && !(ob->id.lib)); +} + int ED_operator_editmesh(bContext *C) { Object *obedit= CTX_data_edit_object(C); -- cgit v1.2.3