[Bf-blender-cvs] [798facb] master: Fix crashes when moving game property with invalid index (from py/redo panel)
Julian Eisel
noreply at git.blender.org
Wed Apr 22 17:20:37 CEST 2015
Commit: 798facbff3a3aca7dc09e4609c2e848cd6bf26c9
Author: Julian Eisel
Date: Wed Apr 22 17:19:23 2015 +0200
Branches: master
https://developer.blender.org/rB798facbff3a3aca7dc09e4609c2e848cd6bf26c9
Fix crashes when moving game property with invalid index (from py/redo
panel)
Also hides index option in redo panel to be consistent with similar
operators
===================================================================
M source/blender/editors/object/object_edit.c
===================================================================
diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c
index 562f566..706ca5f 100644
--- a/source/blender/editors/object/object_edit.c
+++ b/source/blender/editors/object/object_edit.c
@@ -1784,6 +1784,10 @@ static int game_property_move(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
prop = BLI_findlink(&ob->prop, index);
+ /* invalid index */
+ if (prop == NULL)
+ return OPERATOR_CANCELLED;
+
if (dir == GAME_PROPERTY_MOVE_UP) {
otherprop = prop->prev;
}
@@ -1812,10 +1816,11 @@ void OBJECT_OT_game_property_move(wmOperatorType *ot)
{GAME_PROPERTY_MOVE_DOWN, "DOWN", 0, "Down", ""},
{0, NULL, 0, NULL, NULL}
};
+ PropertyRNA *prop;
/* identifiers */
ot->name = "Move Game Property";
- ot->description = "Move game property";
+ ot->description = "Move game property";
ot->idname = "OBJECT_OT_game_property_move";
/* api callbacks */
@@ -1825,7 +1830,9 @@ void OBJECT_OT_game_property_move(wmOperatorType *ot)
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
- RNA_def_int(ot->srna, "index", 0, 0, INT_MAX, "Index", "Property index to move", 0, INT_MAX);
+ /* properties */
+ prop = RNA_def_int(ot->srna, "index", 0, 0, INT_MAX, "Index", "Property index to move", 0, INT_MAX);
+ RNA_def_property_flag(prop, PROP_HIDDEN);
RNA_def_enum(ot->srna, "direction", direction_property_move, 0, "Direction",
"Direction for moving the property");
}
More information about the Bf-blender-cvs
mailing list