[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [33782] trunk/blender/source/blender/ makesrna/intern/rna_object.c: Bugfix [#25298] Nasty group cycle that creates crash blend files is
Joshua Leung
aligorith at gmail.com
Sun Dec 19 11:38:03 CET 2010
Revision: 33782
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=33782
Author: aligorith
Date: 2010-12-19 11:38:02 +0100 (Sun, 19 Dec 2010)
Log Message:
-----------
Bugfix [#25298] Nasty group cycle that creates crash blend files is
allowed
Infinite recursion (manisfesting as a crash) occurred when trying to
set the dupli-group setting on an object, when the object is a member
of the group being set. Added a check and warning for this in RNA to
prevent such setups from occurring in future.
Todo:
The warning report is currently only printed to console as I can't
quite remember how to grab reports pointer without context/operator
pointer available.
Modified Paths:
--------------
trunk/blender/source/blender/makesrna/intern/rna_object.c
Modified: trunk/blender/source/blender/makesrna/intern/rna_object.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_object.c 2010-12-19 09:41:41 UTC (rev 33781)
+++ trunk/blender/source/blender/makesrna/intern/rna_object.c 2010-12-19 10:38:02 UTC (rev 33782)
@@ -34,6 +34,7 @@
#include "DNA_action_types.h"
#include "DNA_customdata_types.h"
#include "DNA_controller_types.h"
+#include "DNA_group_types.h"
#include "DNA_material_types.h"
#include "DNA_mesh_types.h"
#include "DNA_object_force.h"
@@ -42,6 +43,8 @@
#include "DNA_scene_types.h"
#include "DNA_meta_types.h"
+#include "BKE_group.h" /* needed for object_in_group() */
+
#include "BLO_sys_types.h" /* needed for intptr_t used in ED_mesh.h */
#include "ED_mesh.h"
@@ -426,6 +429,20 @@
ED_object_parent(ob, ob->parent, ob->partype, value);
}
+static void rna_Object_dup_group_set(PointerRNA *ptr, PointerRNA value)
+{
+ Object *ob= (Object *)ptr->data;
+ Group *grp = (Group *)value.data;
+
+ /* must not let this be set if the object belongs in this group already,
+ * thus causing a cycle/infinite-recursion leading to crashes on load [#25298]
+ */
+ if (object_in_group(ob, grp) == 0)
+ ob->dup_group = grp;
+ else
+ BKE_report(NULL, RPT_ERROR, "Cannot set dupli-group as object belongs in group being instanced thus causing a cycle");
+}
+
static int rna_VertexGroup_index_get(PointerRNA *ptr)
{
Object *ob= (Object*)ptr->id.data;
@@ -2043,6 +2060,7 @@
prop= RNA_def_property(srna, "dupli_group", PROP_POINTER, PROP_NONE);
RNA_def_property_pointer_sdna(prop, NULL, "dup_group");
RNA_def_property_flag(prop, PROP_EDITABLE);
+ RNA_def_property_pointer_funcs(prop, NULL, "rna_Object_dup_group_set", NULL, NULL);
RNA_def_property_ui_text(prop, "Dupli Group", "Instance an existing group");
RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, "rna_Object_dependency_update");
More information about the Bf-blender-cvs
mailing list