diff options
author | Campbell Barton <ideasman42@gmail.com> | 2014-08-21 11:00:35 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2014-08-21 11:05:47 +0400 |
commit | e44cd30abbe9ae662fb2557f1a1f7a6e5c01498f (patch) | |
tree | f746293e80d9d5b083e1b4fa9b7355e7ce57130e /source/blender/makesrna | |
parent | afa6d4e21f1968f24f8a1ca197cdeb75a70eeb28 (diff) |
Fix T41507: Empty prevents image deletion
Also allow assigning `Object.data = None` from Python
Diffstat (limited to 'source/blender/makesrna')
-rw-r--r-- | source/blender/makesrna/intern/rna_object.c | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/source/blender/makesrna/intern/rna_object.c b/source/blender/makesrna/intern/rna_object.c index 216a99866b3..699bfaa0f93 100644 --- a/source/blender/makesrna/intern/rna_object.c +++ b/source/blender/makesrna/intern/rna_object.c @@ -370,8 +370,14 @@ static void rna_Object_data_set(PointerRNA *ptr, PointerRNA value) Object *ob = (Object *)ptr->data; ID *id = value.data; - if (id == NULL || ob->mode & OB_MODE_EDIT) + if (ob->mode & OB_MODE_EDIT) { return; + } + + /* assigning NULL only for empties */ + if ((id == NULL) && (ob->type != OB_EMPTY)) { + return; + } if (ob->type == OB_EMPTY) { if (ob->data) { @@ -379,7 +385,7 @@ static void rna_Object_data_set(PointerRNA *ptr, PointerRNA value) ob->data = NULL; } - if (id && GS(id->name) == ID_IM) { + if (!id || GS(id->name) == ID_IM) { id_us_plus(id); ob->data = id; } @@ -391,11 +397,10 @@ static void rna_Object_data_set(PointerRNA *ptr, PointerRNA value) if (ob->data) { id_us_min((ID *)ob->data); } - if (id) { - /* no need to type-check here ID. this is done in the _typef() function */ - BLI_assert(OB_DATA_SUPPORT_ID(GS(id->name))); - id_us_plus(id); - } + + /* no need to type-check here ID. this is done in the _typef() function */ + BLI_assert(OB_DATA_SUPPORT_ID(GS(id->name))); + id_us_plus(id); ob->data = id; test_object_materials(G.main, id); |