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:
authorJoshua Leung <aligorith@gmail.com>2010-12-19 13:38:02 +0300
committerJoshua Leung <aligorith@gmail.com>2010-12-19 13:38:02 +0300
commit3bcde46dfae04f4659975d44a1e6837197a2fb18 (patch)
treec5ef6aa22fdc2a1158d2c154be665152e0262a41
parente53921cf40af1ecb7ee9da55401c7c2737ed2c39 (diff)
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.
-rw-r--r--source/blender/makesrna/intern/rna_object.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/source/blender/makesrna/intern/rna_object.c b/source/blender/makesrna/intern/rna_object.c
index 0b2bc8921fb..2c5cddca77f 100644
--- a/source/blender/makesrna/intern/rna_object.c
+++ b/source/blender/makesrna/intern/rna_object.c
@@ -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 @@ static void rna_Object_parent_bone_set(PointerRNA *ptr, const char *value)
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 @@ static void rna_def_object(BlenderRNA *brna)
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");