sequencer clipboard
[blender.git] / source / blender / blenkernel / intern / sequencer.c
index e36e8dc49c4cf95ca6cff161093546ef1a3e3d29..41e51885bfcf21fe1aeb06d8b664bad60237cc47 100644 (file)
@@ -232,11 +232,23 @@ Editing *seq_give_editing(Scene *scene, int alloc)
        return scene->ed;
 }
 
+void seq_free_clipboard(Scene *scene)
+{
+       Editing *ed = scene->ed;
+       Sequence *seq, *nseq;
+
+       for(seq= ed->seqbase_clipboard.first; seq; seq= nseq) {
+               nseq= seq->next;
+               seq_free_sequence(scene, seq);
+       }
+       ed->seqbase_clipboard.first= ed->seqbase_clipboard.last= NULL;
+}
+
 void seq_free_editing(Scene *scene)
 {
        Editing *ed = scene->ed;
        MetaStack *ms;
-       Sequence *seq;
+       Sequence *seq, *nseq;
 
        if(ed==NULL)
                return;
@@ -246,6 +258,8 @@ void seq_free_editing(Scene *scene)
        }
        SEQ_END
 
+       seq_free_clipboard(scene);
+
        while((ms= ed->metastack.first)) {
                BLI_remlink(&ed->metastack, ms);
                MEM_freeN(ms);
@@ -3575,18 +3589,20 @@ void seq_offset_animdata(Scene *scene, Sequence *seq, int ofs)
 }
 
 
-Sequence *get_seq_by_name(Scene *scene, const char *name)
+Sequence *get_seq_by_name(ListBase *seqbase, const char *name, int recursive)
 {
-       Sequence *seq=NULL;
-       Editing *ed= seq_give_editing(scene, FALSE);
-       
-       if(ed==NULL) return NULL;
-       
-       for (seq=ed->seqbase.first; seq; seq=seq->next) {
-               if (strcmp(name, seq->name+2) == 0)
-                       break;
+       Sequence *iseq=NULL;
+       Sequence *rseq=NULL;
+
+       for (iseq=seqbase->first; iseq; iseq=iseq->next) {
+               if (strcmp(name, iseq->name+2) == 0)
+                       return iseq;
+               else if(recursive && (iseq->seqbase.first) && (rseq=get_seq_by_name(&iseq->seqbase, name, 1))) {
+                       return rseq;
+               }
        }
-       return seq;
+
+       return NULL;
 }