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:
authorBastien Montagne <montagne29@wanadoo.fr>2017-10-12 16:54:43 +0300
committerBastien Montagne <montagne29@wanadoo.fr>2017-10-12 16:54:43 +0300
commita51688d0b066f00d5912d677d0f4bdad08b28ea6 (patch)
treeaa4ed2f62e238cc4103e9b1969a88fbf3431c6b1
parent3b4f6996a8fd521b532eff0f8cbcd282d9a2c5b7 (diff)
Fix T53052: ID decrement error when deleting a scene, either python or GUI.
User count of scenes was inconsistant, screens only have 'user_one' kind of owning over scenes, which means they shall never increment or decrement their real user count. And usually, scenes have no real user at all.
-rw-r--r--source/blender/blenkernel/intern/scene.c4
-rw-r--r--source/blender/editors/screen/screen_edit.c5
2 files changed, 7 insertions, 2 deletions
diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c
index d32a3a293fd..4526477cad9 100644
--- a/source/blender/blenkernel/intern/scene.c
+++ b/source/blender/blenkernel/intern/scene.c
@@ -290,7 +290,7 @@ Scene *BKE_scene_copy(Main *bmain, Scene *sce, int type)
ListBase rl, rv;
sce_copy = BKE_scene_add(bmain, sce->id.name + 2);
-
+
rl = sce_copy->r.layers;
rv = sce_copy->r.views;
curvemapping_free_data(&sce_copy->r.mblur_shutter_curve);
@@ -387,6 +387,8 @@ Scene *BKE_scene_copy(Main *bmain, Scene *sce, int type)
}
else {
BKE_id_copy_ex(bmain, (ID *)sce, (ID **)&sce_copy, LIB_ID_COPY_ACTIONS, false);
+ id_us_min(&sce_copy->id);
+ id_us_ensure_real(&sce_copy->id);
/* Extra actions, most notably SCE_FULL_COPY also duplicates several 'children' datablocks... */
diff --git a/source/blender/editors/screen/screen_edit.c b/source/blender/editors/screen/screen_edit.c
index 71b00a0a7c6..c99e452b755 100644
--- a/source/blender/editors/screen/screen_edit.c
+++ b/source/blender/editors/screen/screen_edit.c
@@ -1763,7 +1763,10 @@ bool ED_screen_delete_scene(bContext *C, Scene *scene)
BKE_libblock_remap(bmain, scene, newscene, ID_REMAP_SKIP_INDIRECT_USAGE | ID_REMAP_SKIP_NEVER_NULL_USAGE);
- BKE_libblock_free_us(bmain, scene);
+ id_us_clear_real(&scene->id);
+ if (scene->id.us == 0) {
+ BKE_libblock_free(bmain, scene);
+ }
return true;
}