sequencer copy clipboard wasnt checking if all related strips were selected
authorCampbell Barton <ideasman42@gmail.com>
Thu, 17 Dec 2009 23:29:11 +0000 (23:29 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Thu, 17 Dec 2009 23:29:11 +0000 (23:29 +0000)
source/blender/blenkernel/BKE_sequencer.h
source/blender/blenkernel/intern/sequencer.c
source/blender/editors/space_sequencer/sequencer_edit.c

index 22f9278aa38ef3726e4d5b8d4fab77c5c5f738ba..7c74dd5b3d36167996dee76488383e3143fb3d9c 100644 (file)
@@ -186,6 +186,7 @@ struct ListBase *seq_seqbase(struct ListBase *seqbase, struct Sequence *seq);
 void seq_offset_animdata(struct Scene *scene, struct Sequence *seq, int ofs);
 int shuffle_seq(struct ListBase * seqbasep, struct Sequence *test);
 int shuffle_seq_time(ListBase * seqbasep);
+int seqbase_isolated_sel_check(struct ListBase *seqbase);
 void free_imbuf_seq(struct Scene *scene, struct ListBase * seqbasep, int check_mem_usage);
 
 void seq_update_sound(struct Sequence *seq);
index 8b59c2982e6e3aa7fb7a46ece4dcb22e8e0f1a2a..c92640e295e6be269641ac77b25ea12e682647ae 100644 (file)
@@ -76,7 +76,7 @@ static int seqrecty= 0;
 //static int blender_test_break() {return 0;}
 
 /* **** XXX ******** */
-
+#define SELECT 1
 ListBase seqbase_clipboard;
 int seqbase_clipboard_frame;
 
@@ -3283,6 +3283,42 @@ int seq_single_check(Sequence *seq)
                return 0;
 }
 
+/* check if the selected seq's reference unselected seq's */
+int seqbase_isolated_sel_check(ListBase *seqbase)
+{
+       Sequence *seq;
+       /* is there more than 1 select */
+       int ok= FALSE;
+
+       for(seq= seqbase->first; seq; seq= seq->next) {
+               if(seq->flag & SELECT) {
+                       ok= TRUE;
+                       break;
+               }
+       }
+
+       if(ok == FALSE)
+               return FALSE;
+
+       /* test relationships */
+       for(seq= seqbase->first; seq; seq= seq->next) {
+               if(seq->flag & SELECT) {
+                       if(seq->type & SEQ_EFFECT) {
+                               if(seq->seq1 && (seq->seq1->flag & SELECT)==0) return FALSE;
+                               if(seq->seq2 && (seq->seq2->flag & SELECT)==0) return FALSE;
+                               if(seq->seq3 && (seq->seq3->flag & SELECT)==0) return FALSE;
+                       }
+               }
+               else if(seq->type & SEQ_EFFECT) {
+                       if(seq->seq1 && (seq->seq1->flag & SELECT)) return FALSE;
+                       if(seq->seq2 && (seq->seq2->flag & SELECT)) return FALSE;
+                       if(seq->seq3 && (seq->seq3->flag & SELECT)) return FALSE;
+               }
+       }
+
+       return TRUE;
+}
+
 /* use to impose limits when dragging/extending - so impossible situations dont happen
  * Cant use the SEQ_LEFTSEL and SEQ_LEFTSEL directly because the strip may be in a metastrip */
 void seq_tx_handle_xlimits(Sequence *seq, int leftflag, int rightflag)
@@ -3636,7 +3672,7 @@ void seq_load_apply(Scene *scene, Sequence *seq, SeqLoadInfo *seq_load)
                }
 
                if(seq_load->flag & SEQ_LOAD_REPLACE_SEL) {
-                       seq_load->flag |= 1; /* SELECT */
+                       seq_load->flag |= SELECT;
                        active_seq_set(scene, seq);
                }
 
@@ -3662,7 +3698,7 @@ Sequence *alloc_sequence(ListBase *lb, int cfra, int machine)
        *( (short *)seq->name )= ID_SEQ;
        seq->name[2]= 0;
 
-       seq->flag= 1; /* SELECT */
+       seq->flag= SELECT;
        seq->start= cfra;
        seq->machine= machine;
        seq->mul= 1.0;
index dda5860900b430e3d671946ad6758419cfe7138a..0a12ea2e202949c9d55f70a5016b1c58607e55b0 100644 (file)
@@ -2105,52 +2105,14 @@ static int sequencer_meta_make_exec(bContext *C, wmOperator *op)
        if(ed==NULL)
                return OPERATOR_CANCELLED;
 
-       /* is there more than 1 select */
-       tot= 0;
-       seq= ed->seqbasep->first;
-       while(seq) {
-               if(seq->flag & SELECT) {
-                       tot++;
-               }
-               seq= seq->next;
-       }
-       if(tot < 1) return OPERATOR_CANCELLED;;
-
-
-       /* test relationships */
-       seq= ed->seqbasep->first;
-       while(seq) {
-               if(seq->flag & SELECT) {
-                       channel_max= MAX2(seq->machine, channel_max);
-                       if(seq->type & SEQ_EFFECT) {
-                               if(seq->seq1 &&
-                                  (seq->seq1->flag & SELECT)==0) tot= 0;
-                               if(seq->seq2 &&
-                                  (seq->seq2->flag & SELECT)==0) tot= 0;
-                               if(seq->seq3 &&
-                                  (seq->seq3->flag & SELECT)==0) tot= 0;
-                       }
-               }
-               else if(seq->type & SEQ_EFFECT) {
-                       if(seq->seq1 &&
-                          (seq->seq1->flag & SELECT)) tot= 0;
-                       if(seq->seq2 &&
-                          (seq->seq2->flag & SELECT)) tot= 0;
-                       if(seq->seq3 &&
-                          (seq->seq3->flag & SELECT)) tot= 0;
-               }
-               if(tot==0) break;
-               seq= seq->next;
-       }
-
-       if(tot==0) {
+       if(seqbase_isolated_sel_check(ed->seqbasep)==FALSE) {
                BKE_report(op->reports, RPT_ERROR, "Please select all related strips");
                return OPERATOR_CANCELLED;
        }
 
        /* remove all selected from main list, and put in meta */
 
-       seqm= alloc_sequence(ed->seqbasep, 1, channel_max);
+       seqm= alloc_sequence(ed->seqbasep, 1, 1); /* channel number set later */
        strcpy(seqm->name+2, "MetaStrip");
        seqm->type= SEQ_META;
        seqm->flag= SELECT;
@@ -2159,11 +2121,13 @@ static int sequencer_meta_make_exec(bContext *C, wmOperator *op)
        while(seq) {
                next= seq->next;
                if(seq!=seqm && (seq->flag & SELECT)) {
+                       channel_max= MAX2(seq->machine, channel_max);
                        BLI_remlink(ed->seqbasep, seq);
                        BLI_addtail(&seqm->seqbase, seq);
                }
                seq= next;
        }
+       seqm->machine= channel_max;
        calc_sequence(seqm);
 
        seqm->strip= MEM_callocN(sizeof(Strip), "metastrip");
@@ -2758,9 +2722,10 @@ static void seq_del_sound(Scene *scene, Sequence *seq)
                        seq_del_sound(scene, iseq);
                }
        }
-       else if(seq->sound_handle)
+       else if(seq->sound_handle) {
                sound_delete_handle(scene, seq->sound_handle);
-
+               seq->sound_handle= NULL;
+       }
 }
 
 /* TODO, validate scenes */
@@ -2775,6 +2740,11 @@ static int sequencer_copy_exec(bContext *C, wmOperator *op)
 
        seq_free_clipboard();
 
+       if(seqbase_isolated_sel_check(ed->seqbasep)==FALSE) {
+               BKE_report(op->reports, RPT_ERROR, "Please select all related strips");
+               return OPERATOR_CANCELLED;
+       }
+
        recurs_dupli_seq(scene, ed->seqbasep, &seqbase_clipboard, FALSE);
        seqbase_clipboard_frame= scene->r.cfra;