fix for crash in sequencer introduced with recent cache addition,

- running undo with metastrips would crash immediately.
- freeing a strip without a scene would crash (clipboard does this).
This commit is contained in:
Campbell Barton
2012-09-06 04:45:25 +00:00
parent 86dd087057
commit 3bb17bd64a
6 changed files with 31 additions and 22 deletions

View File

@@ -199,7 +199,7 @@ int BKE_sequencer_recursive_apply(struct Sequence *seq, int (*apply_func)(struct
void BKE_sequencer_free_clipboard(void);
void BKE_sequence_free(struct Scene *scene, struct Sequence *seq);
void BKE_sequence_free(struct Scene *scene, struct Sequence *seq, const int do_cache);
const char *BKE_sequence_give_name(struct Sequence *seq);
void BKE_sequence_calc(struct Scene *scene, struct Sequence *seq);
void BKE_sequence_calc_disp(struct Scene *scene, struct Sequence *seq);

View File

@@ -169,7 +169,7 @@ static void seq_free_strip(Strip *strip)
MEM_freeN(strip);
}
void BKE_sequence_free(Scene *scene, Sequence *seq)
void BKE_sequence_free(Scene *scene, Sequence *seq, const int do_cache)
{
if (seq->strip)
seq_free_strip(seq->strip);
@@ -205,21 +205,32 @@ void BKE_sequence_free(Scene *scene, Sequence *seq)
/* free cached data used by this strip,
* also invalidate cache for all dependent sequences
*
* be _very_ careful here, invalidating cache loops over the scene sequences and
* assumes the listbase is valid for all strips, this may not be the case if lists are being freed.
* this is optional BKE_sequence_invalidate_cache
*/
if (do_cache) {
if (scene) {
BKE_sequence_invalidate_cache(scene, seq);
}
}
MEM_freeN(seq);
}
/* cache must be freed before calling this function
* since it leaves the seqbase in an invalid state */
static void seq_free_sequence_recurse(Scene *scene, Sequence *seq)
{
Sequence *iseq;
Sequence *iseq, *iseq_next;
for (iseq = seq->seqbase.first; iseq; iseq = iseq->next) {
for (iseq = seq->seqbase.first; iseq; iseq = iseq_next) {
iseq_next = iseq->next;
seq_free_sequence_recurse(scene, iseq);
}
BKE_sequence_free(scene, seq);
BKE_sequence_free(scene, seq, FALSE);
}
@@ -240,7 +251,7 @@ static void seq_free_clipboard_recursive(Sequence *seq_parent)
seq_free_clipboard_recursive(seq);
}
BKE_sequence_free(NULL, seq_parent);
BKE_sequence_free(NULL, seq_parent, FALSE);
}
void BKE_sequencer_free_clipboard(void)
@@ -269,22 +280,21 @@ Editing *BKE_sequencer_editing_ensure(Scene *scene)
void BKE_sequencer_editing_free(Scene *scene)
{
Editing *ed = scene->ed;
MetaStack *ms;
Sequence *seq;
if (ed == NULL)
return;
/* this may not be the active scene!, could be smarter about this */
BKE_sequencer_cache_cleanup();
SEQ_BEGIN (ed, seq)
{
BKE_sequence_free(scene, seq);
BKE_sequence_free(scene, seq, FALSE);
}
SEQ_END
while ((ms = ed->metastack.first)) {
BLI_remlink(&ed->metastack, ms);
MEM_freeN(ms);
}
BLI_freelistN(&ed->metastack);
MEM_freeN(ed);

View File

@@ -97,7 +97,6 @@ typedef enum bli_rebase_state {
} bli_rebase_state;
int BLI_rebase_path(char *abs, size_t abs_len, char *rel, size_t rel_len, const char *base_dir, const char *src_dir, const char *dest_dir);
#define BKE_rebase_path BLI_rebase_path /* remove after a 2012 */
char *BLI_last_slash(const char *string);
int BLI_add_slash(char *string);

View File

@@ -852,7 +852,7 @@ void draw_image_seq(const bContext *C, Scene *scene, ARegion *ar, SpaceSeq *sseq
struct ImBuf *ibuf = NULL;
struct ImBuf *scope = NULL;
struct View2D *v2d = &ar->v2d;
int rectx, recty;
/* int rectx, recty; */ /* UNUSED */
float viewrectx, viewrecty;
float render_size = 0.0;
float proxy_size = 100.0;
@@ -874,8 +874,8 @@ void draw_image_seq(const bContext *C, Scene *scene, ARegion *ar, SpaceSeq *sseq
viewrectx = (render_size * (float)scene->r.xsch) / 100.0f;
viewrecty = (render_size * (float)scene->r.ysch) / 100.0f;
rectx = viewrectx + 0.5f;
recty = viewrecty + 0.5f;
/* rectx = viewrectx + 0.5f; */ /* UNUSED */
/* recty = viewrecty + 0.5f; */ /* UNUSED */
if (sseq->mainb == SEQ_DRAW_IMG_IMBUF) {
viewrectx *= scene->r.xasp / scene->r.yasp;

View File

@@ -613,7 +613,7 @@ static void recurs_del_seq_flag(Scene *scene, ListBase *lb, short flag, short de
BLI_remlink(lb, seq);
if (seq == last_seq) BKE_sequencer_active_set(scene, NULL);
if (seq->type == SEQ_TYPE_META) recurs_del_seq_flag(scene, &seq->seqbase, flag, 1);
BKE_sequence_free(scene, seq);
BKE_sequence_free(scene, seq, TRUE);
}
seq = seqn;
}
@@ -1812,7 +1812,7 @@ static int sequencer_separate_images_exec(bContext *C, wmOperator *op)
start_ofs += step;
}
BKE_sequence_free(scene, seq);
BKE_sequence_free(scene, seq, TRUE);
seq = seq->next;
}
else {
@@ -2010,7 +2010,7 @@ static int sequencer_meta_separate_exec(bContext *C, wmOperator *UNUSED(op))
last_seq->seqbase.last = NULL;
BLI_remlink(ed->seqbasep, last_seq);
BKE_sequence_free(scene, last_seq);
BKE_sequence_free(scene, last_seq, TRUE);
/* emtpy meta strip, delete all effects depending on it */
for (seq = ed->seqbasep->first; seq; seq = seq->next)

View File

@@ -170,7 +170,7 @@ static Sequence *rna_Sequences_new_image(ID *id, Editing *ed, ReportList *report
if (seq->strip->stripdata->name[0] == '\0') {
BKE_report(reports, RPT_ERROR, "Sequences.new_image: unable to open image file");
BLI_remlink(&ed->seqbase, seq);
BKE_sequence_free(scene, seq);
BKE_sequence_free(scene, seq, FALSE); /* cache won't have been generated */
return NULL;
}
@@ -315,7 +315,7 @@ static void rna_Sequences_remove(ID *id, Editing *ed, Sequence *seq)
Scene *scene = (Scene *)id;
BLI_remlink(&ed->seqbase, seq);
BKE_sequence_free(scene, seq);
BKE_sequence_free(scene, seq, TRUE);
WM_main_add_notifier(NC_SCENE | ND_SEQUENCER, scene);
}