[Bf-blender-cvs] [cec1691] master: Code Cleanup: Clarify some comments regarding usercount management
Joshua Leung
noreply at git.blender.org
Sat Feb 28 14:37:07 CET 2015
Commit: cec1691a91e90fafe336b708cbcd19ebd249f58d
Author: Joshua Leung
Date: Fri Feb 27 17:03:10 2015 +1300
Branches: master
https://developer.blender.org/rBcec1691a91e90fafe336b708cbcd19ebd249f58d
Code Cleanup: Clarify some comments regarding usercount management
(Note for the uninitiated looking at the diffs: this is very much *not* what
you're probably thinking right now, if you're looking at the line in
act_new_exec())
===================================================================
M source/blender/editors/space_action/action_edit.c
M source/blender/makesrna/intern/rna_space.c
===================================================================
diff --git a/source/blender/editors/space_action/action_edit.c b/source/blender/editors/space_action/action_edit.c
index bc9c578..28e10a9 100644
--- a/source/blender/editors/space_action/action_edit.c
+++ b/source/blender/editors/space_action/action_edit.c
@@ -109,9 +109,11 @@ static int act_new_exec(bContext *C, wmOperator *UNUSED(op))
action = add_empty_action(bmain, "Action");
}
- /* when creating new ID blocks, use is already 1 (fake user),
- * but RNA pointer use also increases user, so this compensates it
+ /* when creating new ID blocks, there is already 1 user (as for all new datablocks),
+ * but the RNA pointer code will assign all the proper users instead, so we compensate
+ * for that here
*/
+ BLI_assert(action->id.us == 1);
action->id.us--;
RNA_id_pointer_create(&action->id, &idptr);
@@ -134,6 +136,8 @@ void ACTION_OT_new(wmOperatorType *ot)
/* api callbacks */
ot->exec = act_new_exec;
+ // TODO: add a new invoke() callback to catch cases where users unexpectedly delete their data
+
/* NOTE: this is used in the NLA too... */
//ot->poll = ED_operator_action_active;
diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c
index 11104dc..9e7d70a 100644
--- a/source/blender/makesrna/intern/rna_space.c
+++ b/source/blender/makesrna/intern/rna_space.c
@@ -1127,7 +1127,7 @@ static void rna_SpaceDopeSheetEditor_action_update(Main *UNUSED(bmain), Scene *s
/* fix id-count of action we're replacing */
id_us_min(&adt->action->id);
- /* show new id-count of action we're replacing */
+ /* assign new action, and adjust the usercounts accordingly */
adt->action = saction->action;
id_us_plus(&adt->action->id);
More information about the Bf-blender-cvs
mailing list