Fixed showstopper (thnx intrr!) bug in sequencer + global undo.

This was actually a wrong pointer check in fileread that caused no harm
in past, but with UI-less file save it wreaked havoc!

Decided to add undo in sequencer window after all... it also involved
saving Meta strip settings in files. Very nice :)
This commit is contained in:
Ton Roosendaal 2004-11-13 12:55:59 +00:00
parent 30c8c7dbc7
commit 9393dd08af
6 changed files with 77 additions and 10 deletions

@ -2437,6 +2437,7 @@ static void direct_link_scene(FileData *fd, Scene *sce)
{
Editing *ed;
Sequence *seq;
MetaStack *ms;
StripElem *se;
int a;
@ -2460,14 +2461,10 @@ static void direct_link_scene(FileData *fd, Scene *sce)
if(sce->ed) {
ed= sce->ed= newdataadr(fd, sce->ed);
ed->metastack.first= ed->metastack.last= 0;
/* recursive link sequences, lb will be correctly initialized */
link_recurs_seq(fd, &ed->seqbase);
ed->seqbasep= &ed->seqbase;
WHILE_SEQ(ed->seqbasep) {
WHILE_SEQ(&ed->seqbase) {
seq->seq1= newdataadr(fd, seq->seq1);
seq->seq2= newdataadr(fd, seq->seq2);
seq->seq3= newdataadr(fd, seq->seq3);
@ -2539,6 +2536,36 @@ static void direct_link_scene(FileData *fd, Scene *sce)
}
}
END_SEQ
/* link metastack, slight abuse of structs here, have to restore pointer to internal part in struct */
{
Sequence temp;
char *poin;
long offset;
int seted=0;
offset= ((long)&(temp.seqbase)) - ((long)&temp);
/* root pointer */
poin= (char *)ed->seqbasep;
poin -= offset;
poin= newdataadr(fd, poin);
if(poin) ed->seqbasep= (ListBase *)(poin+offset);
else ed->seqbasep= &ed->seqbase;
/* stack */
link_list(fd, &(ed->metastack));
for(ms= ed->metastack.first; ms; ms= ms->next) {
ms->parseq= newdataadr(fd, ms->parseq);
poin= (char *)ms->oldbasep;
poin -= offset;
poin= newdataadr(fd, poin);
if(poin) ms->oldbasep= (ListBase *)(poin+offset);
else ms->oldbasep= &ed->seqbase;
}
}
}
direct_link_scriptlink(fd, &sce->scriptlink);
@ -2583,7 +2610,10 @@ static void lib_link_screen(FileData *fd, Main *main)
else if(sl->spacetype==SPACE_IPO) {
SpaceIpo *sipo= (SpaceIpo *)sl;
sipo->editipo= 0;
sipo->from= newlibadr(fd, sc->id.lib, sipo->from);
if(sipo->blocktype==ID_SEQ) sipo->from= NULL; // no libdata
else sipo->from= newlibadr(fd, sc->id.lib, sipo->from);
sipo->ipokey.first= sipo->ipokey.last= 0;
sipo->ipo= newlibadr(fd, sc->id.lib, sipo->ipo);
}
@ -2719,7 +2749,10 @@ void lib_link_screen_restore(Main *newmain, char mode, Scene *curscene)
}
else if(sl->spacetype==SPACE_IPO) {
SpaceIpo *sipo= (SpaceIpo *)sl;
sipo->from= restore_pointer_by_name(newmain, (ID *)sipo->from, 0);
if(sipo->blocktype==ID_SEQ) sipo->from= NULL; // no libdata
else sipo->from= restore_pointer_by_name(newmain, (ID *)sipo->from, 0);
// not free sipo->ipokey, creates dependency with src/
sipo->ipo= restore_pointer_by_name(newmain, (ID *)sipo->ipo, 0);
if(sipo->editipo) MEM_freeN(sipo->editipo);

@ -1063,6 +1063,7 @@ static void write_scenes(WriteData *wd, ListBase *scebase)
Base *base;
Editing *ed;
Sequence *seq;
MetaStack *ms;
Strip *strip;
sce= scebase->first;
@ -1118,6 +1119,11 @@ static void write_scenes(WriteData *wd, ListBase *scebase)
}
}
END_SEQ
/* new; meta stack too, even when its nasty restore code */
for(ms= ed->metastack.first; ms; ms= ms->next) {
writestruct(wd, DATA, "MetaStack", 1, ms);
}
}
write_scriptlink(wd, &sce->scriptlink);

@ -122,8 +122,7 @@ typedef struct Sequence {
void *effectdata; /* Struct pointer for effect settings */
} Sequence;
#
#
typedef struct MetaStack {
struct MetaStack *next, *prev;
ListBase *oldbasep;

@ -785,7 +785,7 @@ void drawseqspace(ScrArea *sa, void *spacedata)
glLoadIdentity();
BIF_GetThemeColor3fv(TH_BACK, col);
if(ed && ed->metastack.first) glClearColor(col[0], col[1], col[2]-1.0, 0.0);
if(ed && ed->metastack.first) glClearColor(col[0], col[1], col[2]-0.1, 0.0);
else glClearColor(col[0], col[1], col[2], 0.0);
glClear(GL_COLOR_BUFFER_BIT);

@ -117,6 +117,8 @@ static void change_plugin_seq(char *str) /* called from fileselect */
last_seq->machine= MAX3(last_seq->seq1->machine, last_seq->seq2->machine, last_seq->seq3->machine);
if( test_overlap_seq(last_seq) ) shuffle_seq(last_seq);
BIF_undo_push("Load/change Sequencer plugin");
}
@ -319,6 +321,8 @@ static void deselect_all_seq(void)
seq->flag &= SEQ_DESEL;
}
END_SEQ
BIF_undo_push("(De)select all Sequencer");
}
static void recurs_sel_seq(Sequence *seqm)
@ -360,6 +364,8 @@ void swap_select_seq(void)
END_SEQ
allqueue(REDRAWSEQ, 0);
BIF_undo_push("Swap select all Sequencer");
}
void mouse_select_seq(void)
@ -414,6 +420,7 @@ void mouse_select_seq(void)
force_draw(0);
if(last_seq) allqueue(REDRAWIPO, 0);
BIF_undo_push("Select Sequencer");
std_rmouse_transform(transform_seq);
}
@ -670,6 +677,7 @@ static void add_image_strips(char *name)
waitcursor(0);
BIF_undo_push("Add image strip Sequencer");
transform_seq('g');
}
@ -704,6 +712,7 @@ static void add_movie_strip(char *name)
waitcursor(0);
BIF_undo_push("Add movie strip Sequencer");
transform_seq('g');
}
@ -732,6 +741,7 @@ static void add_sound_strip(char *name)
waitcursor(0);
BIF_undo_push("Add sound strip Sequencer");
transform_seq('g');
}
@ -924,6 +934,8 @@ static int add_seq_effect(int type)
strip->us= 1;
if(seq->len>0) strip->stripdata= MEM_callocN(seq->len*sizeof(StripElem), "stripelem");
BIF_undo_push("Add effect strip Sequencer");
return 1;
}
@ -947,6 +959,7 @@ static void load_plugin_seq(char *str) /* called from fileselect */
last_seq->machine= MAX3(last_seq->seq1->machine, last_seq->seq2->machine, last_seq->seq3->machine);
if( test_overlap_seq(last_seq) ) shuffle_seq(last_seq);
BIF_undo_push("Add plugin strip Sequencer");
transform_seq('g');
}
}
@ -1071,6 +1084,7 @@ void add_sequence(int type)
strip->us= 1;
if(seq->len>0) strip->stripdata= MEM_callocN(seq->len*sizeof(StripElem), "stripelem");
BIF_undo_push("Add scene strip Sequencer");
transform_seq('g');
}
}
@ -1143,6 +1157,7 @@ void change_sequence(void)
}
new_stripdata(last_seq);
allqueue(REDRAWSEQ, 0);
BIF_undo_push("Change effect Sequencer");
}
}
else if(last_seq->type == SEQ_IMAGE) {
@ -1254,6 +1269,7 @@ void del_seq(void)
ms= ms->prev;
}
BIF_undo_push("Delete from Sequencer");
allqueue(REDRAWSEQ, 0);
}
@ -1402,6 +1418,7 @@ void add_duplicate_seq(void)
recurs_dupli_seq(ed->seqbasep, &new);
addlisttolist(ed->seqbasep, &new);
BIF_undo_push("Add duplicate Sequencer");
transform_seq('g');
}
@ -1502,6 +1519,8 @@ void no_gaps(void)
if(done==0) break;
}
}
BIF_undo_push("No gaps Sequencer");
allqueue(REDRAWSEQ, 0);
}
@ -1578,6 +1597,7 @@ void make_meta(void)
set_meta_stripdata(seqm);
BIF_undo_push("Make Meta Sequencer");
allqueue(REDRAWSEQ, 0);
}
@ -1633,6 +1653,7 @@ void un_meta(void)
}
END_SEQ;
BIF_undo_push("Un-make Meta Sequencer");
allqueue(REDRAWSEQ, 0);
}
@ -1670,6 +1691,8 @@ void exit_meta(void)
MEM_freeN(ms);
allqueue(REDRAWSEQ, 0);
BIF_undo_push("Exit meta strip Sequence");
}
@ -1695,6 +1718,7 @@ void enter_meta(void)
last_seq= 0;
allqueue(REDRAWSEQ, 0);
BIF_undo_push("Enter meta strip Sequence");
}
@ -1953,6 +1977,7 @@ void transform_seq(int mode)
G.moving= 0;
MEM_freeN(transmain);
BIF_undo_push("Transform Sequencer");
allqueue(REDRAWSEQ, 0);
}
@ -2072,6 +2097,7 @@ void seq_snap(short event)
/* as last: */
sort_seq();
BIF_undo_push("Snap menu Sequencer");
allqueue(REDRAWSEQ, 0);
}
@ -2119,6 +2145,7 @@ void borderselect_seq(void)
seq= seq->next;
}
BIF_undo_push("Border select Sequencer");
addqueue(curarea->win, REDRAW, 1);
}
}

@ -3157,10 +3157,12 @@ static void winqreadseqspace(ScrArea *sa, void *spacedata, BWinEvent *evt)
}
else if((G.qual==LR_SHIFTKEY)) {
insert_gap(25, CFRA);
BIF_undo_push("Insert gaps Sequencer");
allqueue(REDRAWSEQ, 0);
}
else if(G.qual==LR_ALTKEY) {
insert_gap(250, CFRA);
BIF_undo_push("Insert gaps Sequencer");
allqueue(REDRAWSEQ, 0);
}
}