Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <campbell@blender.org>2022-08-28 13:08:18 +0300
committerCampbell Barton <campbell@blender.org>2022-08-28 13:18:12 +0300
commit7de290ea086cbcd063a2d5668a74e0f23bc28339 (patch)
tree175c9960d0fc04a7b0553c0195f7aba97d3abe3d /source/blender/editors/object
parent219d1095756fda2e54b6168eb65c93e3869722a6 (diff)
Fix crashes running operators in invalid contexts
Fix for running operators outside of expected contexts. - UI_OT_view_drop (poll) - UI_OT_view_item_rename (poll) - OBJECT_OT_gpencil_modifier_move_to_index - OBJECT_OT_modifier_move_to_index - OBJECT_OT_geometry_nodes_input_attribute_toggle - OBJECT_OT_geometry_node_tree_copy_assign - OBJECT_OT_shaderfx_remove - OBJECT_OT_shaderfx_copy - POSE_OT_relax (& other pose slide operators).
Diffstat (limited to 'source/blender/editors/object')
-rw-r--r--source/blender/editors/object/object_gpencil_modifier.c3
-rw-r--r--source/blender/editors/object/object_modifier.cc7
-rw-r--r--source/blender/editors/object/object_shader_fx.c9
3 files changed, 12 insertions, 7 deletions
diff --git a/source/blender/editors/object/object_gpencil_modifier.c b/source/blender/editors/object/object_gpencil_modifier.c
index 573f048e6b6..42ac6d166b4 100644
--- a/source/blender/editors/object/object_gpencil_modifier.c
+++ b/source/blender/editors/object/object_gpencil_modifier.c
@@ -680,8 +680,7 @@ static int gpencil_modifier_move_to_index_exec(bContext *C, wmOperator *op)
Object *ob = ED_object_active_context(C);
GpencilModifierData *md = gpencil_edit_modifier_property_get(op, ob, 0);
int index = RNA_int_get(op->ptr, "index");
-
- if (!ED_object_gpencil_modifier_move_to_index(op->reports, ob, md, index)) {
+ if (!(md && ED_object_gpencil_modifier_move_to_index(op->reports, ob, md, index))) {
return OPERATOR_CANCELLED;
}
diff --git a/source/blender/editors/object/object_modifier.cc b/source/blender/editors/object/object_modifier.cc
index e7cfcf48fd3..7645af35c23 100644
--- a/source/blender/editors/object/object_modifier.cc
+++ b/source/blender/editors/object/object_modifier.cc
@@ -1363,7 +1363,7 @@ static int modifier_move_to_index_exec(bContext *C, wmOperator *op)
ModifierData *md = edit_modifier_property_get(op, ob, 0);
int index = RNA_int_get(op->ptr, "index");
- if (!ED_object_modifier_move_to_index(op->reports, ob, md, index)) {
+ if (!(md && ED_object_modifier_move_to_index(op->reports, ob, md, index))) {
return OPERATOR_CANCELLED;
}
@@ -3344,6 +3344,7 @@ void OBJECT_OT_geometry_nodes_input_attribute_toggle(wmOperatorType *ot)
ot->idname = "OBJECT_OT_geometry_nodes_input_attribute_toggle";
ot->exec = geometry_nodes_input_attribute_toggle_exec;
+ ot->poll = ED_operator_object_active;
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL;
@@ -3361,9 +3362,8 @@ static int geometry_node_tree_copy_assign_exec(bContext *C, wmOperator *UNUSED(o
{
Main *bmain = CTX_data_main(C);
Object *ob = ED_object_active_context(C);
-
ModifierData *md = BKE_object_active_modifier(ob);
- if (md->type != eModifierType_Nodes) {
+ if (!(md && md->type == eModifierType_Nodes)) {
return OPERATOR_CANCELLED;
}
@@ -3395,6 +3395,7 @@ void OBJECT_OT_geometry_node_tree_copy_assign(wmOperatorType *ot)
ot->idname = "OBJECT_OT_geometry_node_tree_copy_assign";
ot->exec = geometry_node_tree_copy_assign_exec;
+ ot->poll = ED_operator_object_active;
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
diff --git a/source/blender/editors/object/object_shader_fx.c b/source/blender/editors/object/object_shader_fx.c
index dd7fc192dc1..4b721cb65a1 100644
--- a/source/blender/editors/object/object_shader_fx.c
+++ b/source/blender/editors/object/object_shader_fx.c
@@ -481,12 +481,15 @@ static int shaderfx_remove_exec(bContext *C, wmOperator *op)
Main *bmain = CTX_data_main(C);
Object *ob = ED_object_active_context(C);
ShaderFxData *fx = edit_shaderfx_property_get(op, ob, 0);
+ if (!fx) {
+ return OPERATOR_CANCELLED;
+ }
/* Store name temporarily for report. */
char name[MAX_NAME];
strcpy(name, fx->name);
- if (!fx || !ED_object_shaderfx_remove(op->reports, bmain, ob, fx)) {
+ if (!ED_object_shaderfx_remove(op->reports, bmain, ob, fx)) {
return OPERATOR_CANCELLED;
}
@@ -671,7 +674,9 @@ static int shaderfx_copy_exec(bContext *C, wmOperator *op)
{
Object *ob = ED_object_active_context(C);
ShaderFxData *fx = edit_shaderfx_property_get(op, ob, 0);
-
+ if (!fx) {
+ return OPERATOR_CANCELLED;
+ }
ShaderFxData *nfx = BKE_shaderfx_new(fx->type);
if (!nfx) {
return OPERATOR_CANCELLED;