better error reporting for seq_swap()
This commit is contained in:
@@ -279,7 +279,7 @@ int shuffle_seq_time(ListBase * seqbasep, struct Scene *evil_scene);
|
||||
int seqbase_isolated_sel_check(struct ListBase *seqbase);
|
||||
void free_imbuf_seq(struct Scene *scene, struct ListBase * seqbasep, int check_mem_usage, int keep_file_handles);
|
||||
struct Sequence *seq_dupli_recursive(struct Scene *scene, struct Scene *scene_to, struct Sequence * seq, int dupe_flag);
|
||||
int seq_swap(struct Sequence *seq_a, struct Sequence *seq_b);
|
||||
int seq_swap(struct Sequence *seq_a, struct Sequence *seq_b, const char **error_str);
|
||||
|
||||
void seq_update_sound(struct Scene* scene, struct Sequence *seq);
|
||||
void seq_update_muting(struct Scene* scene, struct Editing *ed);
|
||||
|
@@ -3207,26 +3207,30 @@ Sequence *seq_metastrip(ListBase * seqbase, Sequence * meta, Sequence *seq)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int seq_swap(Sequence *seq_a, Sequence *seq_b)
|
||||
int seq_swap(Sequence *seq_a, Sequence *seq_b, const char **error_str)
|
||||
{
|
||||
char name[sizeof(seq_a->name)];
|
||||
|
||||
if(seq_a->len != seq_b->len)
|
||||
*error_str= "Strips must be the same length";
|
||||
return 0;
|
||||
|
||||
/* type checking, could be more advanced but disalow sound vs non-sound copy */
|
||||
if(seq_a->type != seq_b->type) {
|
||||
if(seq_a->type == SEQ_SOUND || seq_b->type == SEQ_SOUND) {
|
||||
*error_str= "Strips were not compatible";
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* disallow effects to swap with non-effects strips */
|
||||
if((seq_a->type & SEQ_EFFECT) != (seq_b->type & SEQ_EFFECT)) {
|
||||
*error_str= "Strips were not compatible";
|
||||
return 0;
|
||||
}
|
||||
|
||||
if((seq_a->type & SEQ_EFFECT) && (seq_b->type & SEQ_EFFECT)) {
|
||||
if(get_sequence_effect_num_inputs(seq_a->type) != get_sequence_effect_num_inputs(seq_b->type)) {
|
||||
*error_str= "Strips must have the same number of inputs";
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
@@ -2719,14 +2719,15 @@ static int sequencer_swap_data_exec(bContext *C, wmOperator *op)
|
||||
Scene *scene= CTX_data_scene(C);
|
||||
Sequence *seq_act;
|
||||
Sequence *seq_other;
|
||||
const char *error_msg;
|
||||
|
||||
if(seq_active_pair_get(scene, &seq_act, &seq_other) == 0) {
|
||||
BKE_report(op->reports, RPT_ERROR, "Must select 2 strips");
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
|
||||
if(seq_swap(seq_act, seq_other) == 0) {
|
||||
BKE_report(op->reports, RPT_ERROR, "Strips were not compatible");
|
||||
if(seq_swap(seq_act, seq_other, &error_msg) == 0) {
|
||||
BKE_report(op->reports, RPT_ERROR, error_msg);
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
|
||||
|
@@ -51,8 +51,10 @@
|
||||
|
||||
static void rna_Sequence_swap_internal(Sequence *seq_self, ReportList *reports, Sequence *seq_other)
|
||||
{
|
||||
if(seq_swap(seq_self, seq_other) == 0)
|
||||
BKE_report(reports, RPT_ERROR, "both strips must be the same length");
|
||||
const char *error_msg;
|
||||
|
||||
if(seq_swap(seq_self, seq_other, &error_msg) == 0)
|
||||
BKE_report(reports, RPT_ERROR, error_msg);
|
||||
}
|
||||
|
||||
#else
|
||||
|
Reference in New Issue
Block a user