[Bf-blender-cvs] [20b6eabd428] blender2.8: Fix (unreported) broken freeing code for Sequencer.

Bastien Montagne noreply at git.blender.org
Fri May 11 11:36:56 CEST 2018


Commit: 20b6eabd4282890f2d990fcb31555ff34699d861
Author: Bastien Montagne
Date:   Fri May 11 11:21:30 2018 +0200
Branches: blender2.8
https://developer.blender.org/rB20b6eabd4282890f2d990fcb31555ff34699d861

Fix (unreported) broken freeing code for Sequencer.

Freeing sequencer would always do usercount, which is now forbidden when
called from main ID freeing code.

Annoying in 2.7x, much more critical issue in 2.8!

Also, moved RNA sequencer API functions to proper rna_scene_api.c file.

===================================================================

M	source/blender/blenkernel/BKE_sequencer.h
M	source/blender/blenkernel/intern/scene.c
M	source/blender/blenkernel/intern/sequencer.c
M	source/blender/makesrna/intern/rna_scene.c
M	source/blender/makesrna/intern/rna_scene_api.c

===================================================================

diff --git a/source/blender/blenkernel/BKE_sequencer.h b/source/blender/blenkernel/BKE_sequencer.h
index cd173ef33ce..cbe7c0b7743 100644
--- a/source/blender/blenkernel/BKE_sequencer.h
+++ b/source/blender/blenkernel/BKE_sequencer.h
@@ -209,7 +209,7 @@ void BKE_sequencer_pixel_from_sequencer_space_v4(struct Scene *scene, float pixe
  * ********************************************************************** */
 struct Editing  *BKE_sequencer_editing_get(struct Scene *scene, bool alloc);
 struct Editing  *BKE_sequencer_editing_ensure(struct Scene *scene);
-void             BKE_sequencer_editing_free(struct Scene *scene);
+void             BKE_sequencer_editing_free(struct Scene *scene, const bool do_id_user);
 
 void             BKE_sequencer_sort(struct Scene *scene);
 
diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c
index 90906d2fef1..f20d48c5eef 100644
--- a/source/blender/blenkernel/intern/scene.c
+++ b/source/blender/blenkernel/intern/scene.c
@@ -427,7 +427,7 @@ Scene *BKE_scene_copy(Main *bmain, Scene *sce, int type)
 			/* Remove sequencer if not full copy */
 			/* XXX Why in Hell? :/ */
 			remove_sequencer_fcurves(sce_copy);
-			BKE_sequencer_editing_free(sce_copy);
+			BKE_sequencer_editing_free(sce_copy, true);
 		}
 
 		/* NOTE: part of SCE_COPY_LINK_DATA and SCE_COPY_FULL operations
@@ -463,7 +463,7 @@ void BKE_scene_free_ex(Scene *sce, const bool do_id_user)
 	/* check all sequences */
 	BKE_sequencer_clear_scene_in_allseqs(G.main, sce);
 
-	BKE_sequencer_editing_free(sce);
+	BKE_sequencer_editing_free(sce, do_id_user);
 
 	BKE_keyingsets_free(&sce->keyingsets);
 
diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c
index a282f535df6..fb619f6c567 100644
--- a/source/blender/blenkernel/intern/sequencer.c
+++ b/source/blender/blenkernel/intern/sequencer.c
@@ -205,7 +205,7 @@ static void seq_free_strip(Strip *strip)
 }
 
 /* only give option to skip cache locally (static func) */
-static void BKE_sequence_free_ex(Scene *scene, Sequence *seq, const bool do_cache)
+static void BKE_sequence_free_ex(Scene *scene, Sequence *seq, const bool do_cache, const bool do_id_user)
 {
 	if (seq->strip)
 		seq_free_strip(seq->strip);
@@ -218,7 +218,7 @@ static void BKE_sequence_free_ex(Scene *scene, Sequence *seq, const bool do_cach
 		sh.free(seq);
 	}
 
-	if (seq->sound) {
+	if (seq->sound && do_id_user) {
 		id_us_min(((ID *)seq->sound));
 	}
 
@@ -242,7 +242,7 @@ static void BKE_sequence_free_ex(Scene *scene, Sequence *seq, const bool do_cach
 	}
 
 	if (seq->prop) {
-		IDP_FreeProperty(seq->prop);
+		IDP_FreeProperty_ex(seq->prop, do_id_user);
 		MEM_freeN(seq->prop);
 	}
 
@@ -267,7 +267,7 @@ static void BKE_sequence_free_ex(Scene *scene, Sequence *seq, const bool do_cach
 
 void BKE_sequence_free(Scene *scene, Sequence *seq)
 {
-	BKE_sequence_free_ex(scene, seq, true);
+	BKE_sequence_free_ex(scene, seq, true, true);
 }
 
 /* Function to free imbuf and anim data on changes */
@@ -297,7 +297,7 @@ static void seq_free_sequence_recurse(Scene *scene, Sequence *seq)
 		seq_free_sequence_recurse(scene, iseq);
 	}
 
-	BKE_sequence_free_ex(scene, seq, false);
+	BKE_sequence_free_ex(scene, seq, false, true);
 }
 
 
@@ -459,7 +459,7 @@ Editing *BKE_sequencer_editing_ensure(Scene *scene)
 	return scene->ed;
 }
 
-void BKE_sequencer_editing_free(Scene *scene)
+void BKE_sequencer_editing_free(Scene *scene, const bool do_id_user)
 {
 	Editing *ed = scene->ed;
 	Sequence *seq;
@@ -473,7 +473,7 @@ void BKE_sequencer_editing_free(Scene *scene)
 	SEQ_BEGIN (ed, seq)
 	{
 		/* handle cache freeing above */
-		BKE_sequence_free_ex(scene, seq, false);
+		BKE_sequence_free_ex(scene, seq, false, do_id_user);
 	}
 	SEQ_END
 
diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c
index 11bee28ed7a..d7aa544fd37 100644
--- a/source/blender/makesrna/intern/rna_scene.c
+++ b/source/blender/makesrna/intern/rna_scene.c
@@ -5912,14 +5912,6 @@ void RNA_def_scene(BlenderRNA *brna)
 	RNA_def_property_struct_type(prop, "SequenceEditor");
 	RNA_def_property_ui_text(prop, "Sequence Editor", "");
 	
-	func = RNA_def_function(srna, "sequence_editor_create", "BKE_sequencer_editing_ensure");
-	RNA_def_function_ui_description(func, "Ensure sequence editor is valid in this scene");
-	parm = RNA_def_pointer(func, "sequence_editor", "SequenceEditor", "", "New sequence editor data or NULL");
-	RNA_def_function_return(func, parm);
-
-	func = RNA_def_function(srna, "sequence_editor_clear", "BKE_sequencer_editing_free");
-	RNA_def_function_ui_description(func, "Clear sequence editor in this scene");
-
 	/* Keying Sets */
 	prop = RNA_def_property(srna, "keying_sets", PROP_COLLECTION, PROP_NONE);
 	RNA_def_property_collection_sdna(prop, NULL, "keyingsets", NULL);
diff --git a/source/blender/makesrna/intern/rna_scene_api.c b/source/blender/makesrna/intern/rna_scene_api.c
index ca7d153066f..a3e403154f9 100644
--- a/source/blender/makesrna/intern/rna_scene_api.c
+++ b/source/blender/makesrna/intern/rna_scene_api.c
@@ -197,6 +197,11 @@ static void rna_Scene_ray_cast(
 	}
 }
 
+static void rna_Scene_sequencer_editing_free(Scene *scene)
+{
+	BKE_sequencer_editing_free(scene, true);
+}
+
 #ifdef WITH_ALEMBIC
 
 static void rna_Scene_alembic_export(
@@ -331,6 +336,14 @@ void RNA_api_scene(StructRNA *srna)
 	parm = RNA_def_float_matrix(func, "matrix", 4, 4, NULL, 0.0f, 0.0f, "", "Matrix", 0.0f, 0.0f);
 	RNA_def_function_output(func, parm);
 
+	/* Sequencer. */
+	func = RNA_def_function(srna, "sequence_editor_create", "BKE_sequencer_editing_ensure");
+	RNA_def_function_ui_description(func, "Ensure sequence editor is valid in this scene");
+	parm = RNA_def_pointer(func, "sequence_editor", "SequenceEditor", "", "New sequence editor data or NULL");
+	RNA_def_function_return(func, parm);
+
+	func = RNA_def_function(srna, "sequence_editor_clear", "rna_Scene_sequencer_editing_free");
+	RNA_def_function_ui_description(func, "Clear sequence editor in this scene");
 
 #ifdef WITH_ALEMBIC
 	/* XXX Deprecated, will be removed in 2.8 in favour of calling the export operator. */



More information about the Bf-blender-cvs mailing list