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.
This commit is contained in:
Bastien Montagne 2018-05-11 11:21:30 +02:00
parent 8b41999ea0
commit 20b6eabd42
5 changed files with 23 additions and 18 deletions

View File

@ -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);

View File

@ -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);

View File

@ -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

View File

@ -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);

View File

@ -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. */