Fix #32755: Stripes in Metastrip can not be moved on other channel with mouse (grab...
authorSergey Sharybin <sergey.vfx@gmail.com>
Thu, 4 Oct 2012 18:30:28 +0000 (18:30 +0000)
committerSergey Sharybin <sergey.vfx@gmail.com>
Thu, 4 Oct 2012 18:30:28 +0000 (18:30 +0000)
The issue was caused by SEQ_BEGIN macro modifying sequence's depth
which ruined transformation routines. Used own DFS instead which
doesn't modify sequences.

Also corrected some typos in api and comments.

source/blender/blenkernel/BKE_sequencer.h
source/blender/blenkernel/intern/image.c
source/blender/blenkernel/intern/sequencer.c
source/blender/blenloader/intern/versioning_250.c
source/blender/editors/space_sequencer/sequencer_add.c
source/blender/editors/space_sequencer/sequencer_draw.c
source/blender/editors/space_sequencer/sequencer_edit.c
source/blender/editors/space_sequencer/sequencer_select.c
source/blender/editors/transform/transform_generics.c
source/blender/makesrna/intern/rna_sequencer.c
source/blender/makesrna/intern/rna_sequencer_api.c

index 0c571f6..cecff2d 100644 (file)
@@ -64,29 +64,29 @@ typedef struct SeqIterator {
        int valid;
 } SeqIterator;
 
-void BKE_seqence_iterator_begin(struct Editing *ed, SeqIterator *iter, int use_pointer);
-void BKE_seqence_iterator_next(SeqIterator *iter);
-void BKE_seqence_iterator_end(SeqIterator *iter);
+void BKE_sequence_iterator_begin(struct Editing *ed, SeqIterator *iter, int use_pointer);
+void BKE_sequence_iterator_next(SeqIterator *iter);
+void BKE_sequence_iterator_end(SeqIterator *iter);
 
 #define SEQP_BEGIN(ed, _seq)                                                  \
        {                                                                         \
                SeqIterator iter;                                                     \
-               for (BKE_seqence_iterator_begin(ed, &iter, 1);                        \
+               for (BKE_sequence_iterator_begin(ed, &iter, 1);                       \
                     iter.valid;                                                      \
-                    BKE_seqence_iterator_next(&iter)) {                              \
+                    BKE_sequence_iterator_next(&iter)) {                             \
                        _seq = iter.seq;
                        
 #define SEQ_BEGIN(ed, _seq)                                                   \
        {                                                                         \
                SeqIterator iter;                                                     \
-               for (BKE_seqence_iterator_begin(ed, &iter, 0);                        \
+               for (BKE_sequence_iterator_begin(ed, &iter, 0);                       \
                     iter.valid;                                                      \
-                    BKE_seqence_iterator_next(&iter)) {                              \
+                    BKE_sequence_iterator_next(&iter)) {                             \
                        _seq = iter.seq;
 
 #define SEQ_END                                                               \
                }                                                                     \
-               BKE_seqence_iterator_end(&iter);                                      \
+               BKE_sequence_iterator_end(&iter);                                     \
        }
 
 typedef struct SeqRenderData {
@@ -307,7 +307,7 @@ int BKE_sequence_swap(struct Sequence *seq_a, struct Sequence *seq_b, const char
 
 int BKE_sequence_check_depend(struct Sequence *seq, struct Sequence *cur);
 void BKE_sequence_invalidate_cache(struct Scene *scene, struct Sequence *seq);
-void BKE_sequence_invalidate_deendent(struct Scene *scene, struct Sequence *seq);
+void BKE_sequence_invalidate_dependent(struct Scene *scene, struct Sequence *seq);
 void BKE_sequence_invalidate_cache_for_modifier(struct Scene *scene, struct Sequence *seq);
 
 void BKE_sequencer_update_sound_bounds_all(struct Scene *scene);
@@ -315,9 +315,9 @@ void BKE_sequencer_update_sound_bounds(struct Scene *scene, struct Sequence *seq
 void BKE_sequencer_update_muting(struct Editing *ed);
 void BKE_sequencer_update_sound(struct Scene *scene, struct bSound *sound);
 
-void BKE_seqence_base_unique_name_recursive(ListBase *seqbasep, struct Sequence *seq);
+void BKE_sequence_base_unique_name_recursive(ListBase *seqbasep, struct Sequence *seq);
 void BKE_sequence_base_dupli_recursive(struct Scene *scene, struct Scene *scene_to, ListBase *nseqbase, ListBase *seqbase, int dupe_flag);
-int  BKE_seqence_is_valid_check(struct Sequence *seq);
+int  BKE_sequence_is_valid_check(struct Sequence *seq);
 
 void BKE_sequencer_clear_scene_in_allseqs(struct Main *bmain, struct Scene *sce);
 
index 3d3afa7..c003a86 100644 (file)
@@ -2563,7 +2563,7 @@ static ImBuf *image_get_render_result(Image *ima, ImageUser *iuser, void **lock_
                *lock_r = re;
        }
 
-       /* this gives active layer, composite or seqence result */
+       /* this gives active layer, composite or sequence result */
        rect = (unsigned int *)rres.rect32;
        rectf = rres.rectf;
        rectz = rres.rectz;
index 37f32a1..90c3347 100644 (file)
@@ -461,7 +461,7 @@ static void seq_array(Editing *ed, Sequence ***seqarray, int *tot, int use_point
                seq_build_array(&ed->seqbase, &array, 0);
 }
 
-void BKE_seqence_iterator_begin(Editing *ed, SeqIterator *iter, int use_pointer)
+void BKE_sequence_iterator_begin(Editing *ed, SeqIterator *iter, int use_pointer)
 {
        memset(iter, 0, sizeof(*iter));
        seq_array(ed, &iter->array, &iter->tot, use_pointer);
@@ -473,7 +473,7 @@ void BKE_seqence_iterator_begin(Editing *ed, SeqIterator *iter, int use_pointer)
        }
 }
 
-void BKE_seqence_iterator_next(SeqIterator *iter)
+void BKE_sequence_iterator_next(SeqIterator *iter)
 {
        if (++iter->cur < iter->tot)
                iter->seq = iter->array[iter->cur];
@@ -481,7 +481,7 @@ void BKE_seqence_iterator_next(SeqIterator *iter)
                iter->valid = 0;
 }
 
-void BKE_seqence_iterator_end(SeqIterator *iter)
+void BKE_sequence_iterator_end(SeqIterator *iter)
 {
        if (iter->array)
                MEM_freeN(iter->array);
@@ -843,7 +843,7 @@ static int seqbase_unique_name_recursive_cb(Sequence *seq, void *arg_pt)
        return 1;
 }
 
-void BKE_seqence_base_unique_name_recursive(ListBase *seqbasep, Sequence *seq)
+void BKE_sequence_base_unique_name_recursive(ListBase *seqbasep, Sequence *seq)
 {
        SeqUniqueInfo sui;
        char *dot;
@@ -3032,10 +3032,27 @@ int BKE_sequence_check_depend(Sequence *seq, Sequence *cur)
        return TRUE;
 }
 
+static void sequence_do_invalidate_dependent(Sequence *seq, ListBase *seqbase)
+{
+       Sequence *cur;
+
+       for (cur = seqbase->first; cur; cur = cur->next) {
+               if (cur == seq)
+                       continue;
+
+               if (BKE_sequence_check_depend(seq, cur)) {
+                       BKE_sequencer_cache_cleanup_sequence(cur);
+                       BKE_sequencer_preprocessed_cache_cleanup_sequence(cur);
+               }
+
+               if (cur->seqbase.first)
+                       sequence_do_invalidate_dependent(seq, &cur->seqbase);
+       }
+}
+
 static void sequence_invalidate_cache(Scene *scene, Sequence *seq, int invalidate_self, int invalidate_preprocess)
 {
        Editing *ed = scene->ed;
-       Sequence *cur;
 
        /* invalidate cache for current sequence */
        if (invalidate_self)
@@ -3049,17 +3066,11 @@ static void sequence_invalidate_cache(Scene *scene, Sequence *seq, int invalidat
                BKE_sequencer_preprocessed_cache_cleanup_sequence(seq);
 
        /* invalidate cache for all dependent sequences */
-       SEQ_BEGIN (ed, cur)
-       {
-               if (cur == seq)
-                       continue;
 
-               if (BKE_sequence_check_depend(seq, cur)) {
-                       BKE_sequencer_cache_cleanup_sequence(cur);
-                       BKE_sequencer_preprocessed_cache_cleanup_sequence(cur);
-               }
-       }
-       SEQ_END
+       /* NOTE: can not use SEQ_BEGIN/SEQ_END here because that macro will change sequence's depth,
+        *       which makes transformation routines work incorrect
+        */
+       sequence_do_invalidate_dependent(seq, &ed->seqbase);
 }
 
 void BKE_sequence_invalidate_cache(Scene *scene, Sequence *seq)
@@ -3067,7 +3078,7 @@ void BKE_sequence_invalidate_cache(Scene *scene, Sequence *seq)
        sequence_invalidate_cache(scene, seq, TRUE, TRUE);
 }
 
-void BKE_sequence_invalidate_deendent(Scene *scene, Sequence *seq)
+void BKE_sequence_invalidate_dependent(Scene *scene, Sequence *seq)
 {
        sequence_invalidate_cache(scene, seq, FALSE, TRUE);
 }
@@ -3872,7 +3883,7 @@ static void seq_load_apply(Scene *scene, Sequence *seq, SeqLoadInfo *seq_load)
 {
        if (seq) {
                BLI_strncpy(seq->name + 2, seq_load->name, sizeof(seq->name) - 2);
-               BKE_seqence_base_unique_name_recursive(&scene->ed->seqbase, seq);
+               BKE_sequence_base_unique_name_recursive(&scene->ed->seqbase, seq);
 
                if (seq_load->flag & SEQ_LOAD_FRAME_ADVANCE) {
                        seq_load->start_frame += (seq->enddisp - seq->startdisp);
@@ -3983,7 +3994,7 @@ Sequence *BKE_sequencer_add_sound_strip(bContext *C, ListBase *seqbasep, SeqLoad
        seq->type = SEQ_TYPE_SOUND_RAM;
        seq->sound = sound;
        BLI_strncpy(seq->name + 2, "Sound", SEQ_NAME_MAXSTR - 2);
-       BKE_seqence_base_unique_name_recursive(&scene->ed->seqbase, seq);
+       BKE_sequence_base_unique_name_recursive(&scene->ed->seqbase, seq);
 
        /* basic defaults */
        seq->strip = strip = MEM_callocN(sizeof(Strip), "strip");
@@ -4043,7 +4054,7 @@ Sequence *BKE_sequencer_add_movie_strip(bContext *C, ListBase *seqbasep, SeqLoad
        seq->anim = an;
        seq->anim_preseek = IMB_anim_get_preseek(an);
        BLI_strncpy(seq->name + 2, "Movie", SEQ_NAME_MAXSTR - 2);
-       BKE_seqence_base_unique_name_recursive(&scene->ed->seqbase, seq);
+       BKE_sequence_base_unique_name_recursive(&scene->ed->seqbase, seq);
 
        /* basic defaults */
        seq->strip = strip = MEM_callocN(sizeof(Strip), "strip");
@@ -4155,7 +4166,7 @@ static Sequence *seq_dupli(Scene *scene, Scene *scene_to, Sequence *seq, int dup
        }
 
        if (dupe_flag & SEQ_DUPE_UNIQUE_NAME)
-               BKE_seqence_base_unique_name_recursive(&scene->ed->seqbase, seqn);
+               BKE_sequence_base_unique_name_recursive(&scene->ed->seqbase, seqn);
 
        if (dupe_flag & SEQ_DUPE_ANIM)
                BKE_sequencer_dupe_animdata(scene, seq->name + 2, seqn->name + 2);
@@ -4210,7 +4221,7 @@ void BKE_sequence_base_dupli_recursive(Scene *scene, Scene *scene_to, ListBase *
 
 /* called on draw, needs to be fast,
  * we could cache and use a flag if we want to make checks for file paths resolving for eg. */
-int BKE_seqence_is_valid_check(Sequence *seq)
+int BKE_sequence_is_valid_check(Sequence *seq)
 {
        switch (seq->type) {
                case SEQ_TYPE_MASK:
index a4f190c..a3cfa44 100644 (file)
@@ -652,7 +652,7 @@ static void do_versions_seq_unique_name_all_strips(Scene * sce, ListBase *seqbas
        Sequence * seq = seqbasep->first;
 
        while (seq) {
-               BKE_seqence_base_unique_name_recursive(&sce->ed->seqbase, seq);
+               BKE_sequence_base_unique_name_recursive(&sce->ed->seqbase, seq);
                if (seq->seqbase.first) {
                        do_versions_seq_unique_name_all_strips(sce, &seq->seqbase);
                }
index 7b7170d..ff895c0 100644 (file)
@@ -242,7 +242,7 @@ static int sequencer_add_scene_strip_exec(bContext *C, wmOperator *op)
        strip->us = 1;
        
        BLI_strncpy(seq->name + 2, sce_seq->id.name + 2, sizeof(seq->name) - 2);
-       BKE_seqence_base_unique_name_recursive(&ed->seqbase, seq);
+       BKE_sequence_base_unique_name_recursive(&ed->seqbase, seq);
 
        seq->scene_sound = sound_scene_add_scene_sound(scene, seq, start_frame, start_frame + seq->len, 0);
 
@@ -343,7 +343,7 @@ static int sequencer_add_movieclip_strip_exec(bContext *C, wmOperator *op)
        strip->us = 1;
        
        BLI_strncpy(seq->name + 2, clip->id.name + 2, sizeof(seq->name) - 2);
-       BKE_seqence_base_unique_name_recursive(&ed->seqbase, seq);
+       BKE_sequence_base_unique_name_recursive(&ed->seqbase, seq);
 
        BKE_sequence_calc_disp(scene, seq);
        BKE_sequencer_sort(scene);
@@ -439,7 +439,7 @@ static int sequencer_add_mask_strip_exec(bContext *C, wmOperator *op)
        strip->us = 1;
 
        BLI_strncpy(seq->name + 2, mask->id.name + 2, sizeof(seq->name) - 2);
-       BKE_seqence_base_unique_name_recursive(&ed->seqbase, seq);
+       BKE_sequence_base_unique_name_recursive(&ed->seqbase, seq);
 
        BKE_sequence_calc_disp(scene, seq);
        BKE_sequencer_sort(scene);
@@ -820,7 +820,7 @@ static int sequencer_add_effect_strip_exec(bContext *C, wmOperator *op)
        seq->type = type;
 
        BLI_strncpy(seq->name + 2, BKE_sequence_give_name(seq), sizeof(seq->name) - 2);
-       BKE_seqence_base_unique_name_recursive(&ed->seqbase, seq);
+       BKE_sequence_base_unique_name_recursive(&ed->seqbase, seq);
 
        sh = BKE_sequence_get_effect(seq);
 
index c72bff1..7bec530 100644 (file)
@@ -747,7 +747,7 @@ static void draw_seq_strip(Scene *scene, ARegion *ar, Sequence *seq, int outline
                glDisable(GL_BLEND);
        }
 
-       if (!BKE_seqence_is_valid_check(seq)) {
+       if (!BKE_sequence_is_valid_check(seq)) {
                glEnable(GL_POLYGON_STIPPLE);
 
                /* panic! */
index e7d964b..204930e 100644 (file)
@@ -1143,13 +1143,13 @@ static int sequencer_mute_exec(bContext *C, wmOperator *op)
                        if (selected) { /* mute unselected */
                                if (seq->flag & SELECT) {
                                        seq->flag |= SEQ_MUTE;
-                                       BKE_sequence_invalidate_deendent(scene, seq);
+                                       BKE_sequence_invalidate_dependent(scene, seq);
                                }
                        }
                        else {
                                if ((seq->flag & SELECT) == 0) {
                                        seq->flag |= SEQ_MUTE;
-                                       BKE_sequence_invalidate_deendent(scene, seq);
+                                       BKE_sequence_invalidate_dependent(scene, seq);
                                }
                        }
                }
@@ -1194,13 +1194,13 @@ static int sequencer_unmute_exec(bContext *C, wmOperator *op)
                        if (selected) { /* unmute unselected */
                                if (seq->flag & SELECT) {
                                        seq->flag &= ~SEQ_MUTE;
-                                       BKE_sequence_invalidate_deendent(scene, seq);
+                                       BKE_sequence_invalidate_dependent(scene, seq);
                                }
                        }
                        else {
                                if ((seq->flag & SELECT) == 0) {
                                        seq->flag &= ~SEQ_MUTE;
-                                       BKE_sequence_invalidate_deendent(scene, seq);
+                                       BKE_sequence_invalidate_dependent(scene, seq);
                                }
                        }
                }
@@ -1573,7 +1573,7 @@ static int apply_unique_name_cb(Sequence *seq, void *arg_pt)
        char name[sizeof(seq->name) - 2];
 
        strcpy(name, seq->name + 2);
-       BKE_seqence_base_unique_name_recursive(&scene->ed->seqbase, seq);
+       BKE_sequence_base_unique_name_recursive(&scene->ed->seqbase, seq);
        BKE_sequencer_dupe_animdata(scene, name, seq->name + 2);
        return 1;
 
@@ -1968,7 +1968,7 @@ static int sequencer_meta_make_exec(bContext *C, wmOperator *op)
 
        BKE_sequencer_update_muting(ed);
 
-       BKE_seqence_base_unique_name_recursive(&scene->ed->seqbase, seqm);
+       BKE_sequence_base_unique_name_recursive(&scene->ed->seqbase, seqm);
 
        WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
 
index 3d57f2f..be33b78 100644 (file)
@@ -1109,7 +1109,7 @@ static short select_grouped_effect_link(Editing *ed, Sequence *actseq)
 
        actseq->tmp = SET_INT_IN_POINTER(TRUE);
 
-       for (BKE_seqence_iterator_begin(ed, &iter, TRUE); iter.valid; BKE_seqence_iterator_next(&iter)) {
+       for (BKE_sequence_iterator_begin(ed, &iter, TRUE); iter.valid; BKE_sequence_iterator_next(&iter)) {
                seq = iter.seq;
 
                /* Ignore all seqs already selected! */
@@ -1137,8 +1137,8 @@ static short select_grouped_effect_link(Editing *ed, Sequence *actseq)
                        changed = TRUE;
 
                        /* Unfortunately, we must restart checks from the beginning. */
-                       BKE_seqence_iterator_end(&iter);
-                       BKE_seqence_iterator_begin(ed, &iter, TRUE);
+                       BKE_sequence_iterator_end(&iter);
+                       BKE_sequence_iterator_begin(ed, &iter, TRUE);
                }
 
                /* Video strips bellow active one, or any strip for audio (order do no matters here!). */
@@ -1147,7 +1147,7 @@ static short select_grouped_effect_link(Editing *ed, Sequence *actseq)
                        changed = TRUE;
                }
        }
-       BKE_seqence_iterator_end(&iter);
+       BKE_sequence_iterator_end(&iter);
 
        return changed;
 }
index b8db0b5..a9d9ec7 100644 (file)
@@ -895,16 +895,20 @@ static void recalcData_view3d(TransInfo *t)
 /* helper for recalcData() - for sequencer transforms */
 static void recalcData_sequencer(TransInfo *t)
 {
-       Editing *ed = BKE_sequencer_editing_get(t->scene, FALSE);
-       Sequence *seq;
+       TransData *td;
+       int a;
+       Sequence *seq_prev = NULL;
 
-       SEQ_BEGIN(ed, seq)
-       {
-               if (seq->flag & SELECT) {
-                       BKE_sequence_invalidate_deendent(t->scene, seq);
+       for (a = 0, td = t->data; a < t->total; a++, td++) {
+               TransDataSeq *tdsq = (TransDataSeq *) td->extra;
+               Sequence *seq = tdsq->seq;
+
+               if (seq != seq_prev) {
+                       BKE_sequence_invalidate_dependent(t->scene, seq);
                }
+
+               seq_prev = seq;
        }
-       SEQ_END
 
        BKE_sequencer_preprocessed_cache_cleanup();
 
index 5c6d05d..e3ef262 100644 (file)
@@ -405,7 +405,7 @@ static void rna_Sequence_name_set(PointerRNA *ptr, const char *value)
        BLI_strncpy_utf8(seq->name + 2, value, sizeof(seq->name) - 2);
        
        /* make sure the name is unique */
-       BKE_seqence_base_unique_name_recursive(&scene->ed->seqbase, seq);
+       BKE_sequence_base_unique_name_recursive(&scene->ed->seqbase, seq);
        
        /* fix all the animation data which may link to this */
 
index c7c4b08..f63ef6c 100644 (file)
@@ -81,7 +81,7 @@ static Sequence *alloc_generic_sequence(Editing *ed, const char *name, int start
        seq->type = type;
 
        BLI_strncpy(seq->name + 2, name, sizeof(seq->name) - 2);
-       BKE_seqence_base_unique_name_recursive(&ed->seqbase, seq);
+       BKE_sequence_base_unique_name_recursive(&ed->seqbase, seq);
 
        seq->strip = strip = MEM_callocN(sizeof(Strip), "strip");
        seq->strip->us = 1;