File name (40) and dirname (80) were too short in sequence data. Made it
compliant using defines FILE_MAXFILE and FILE_MAXDIR.
Also replaced all strcpy() and strcat() with strncpy/strncat, with the
defines in it.
Oh, also fixed plugin path length for sequence, was just 80!

Bug fix #2366

Restored old convention that made using SHIFT+CTRL while using button-
sliders go with 0.1 stepsize of CTRL.
(noticed too late that Chris Burt assigned to self... sorry!)
This commit is contained in:
2005-03-24 09:37:06 +00:00
parent 8b69f0cfd9
commit 7b6ec97182
6 changed files with 65 additions and 45 deletions

View File

@@ -42,8 +42,10 @@
struct Ipo;
struct Scene;
/* strlens; 80= FILE_MAXFILE, 160= FILE_MAXDIR */
typedef struct StripElem {
char name[40];
char name[80];
struct ImBuf *ibuf;
struct StripElem *se1, *se2, *se3;
short ok, nr;
@@ -55,7 +57,7 @@ typedef struct Strip {
struct Strip *next, *prev;
short rt, len, us, done;
StripElem *stripdata;
char dir[80];
char dir[160];
short orx, ory;
int pad;
@@ -63,7 +65,7 @@ typedef struct Strip {
typedef struct PluginSeq {
char name[80];
char name[256];
void *handle;
char *pname;

View File

@@ -526,7 +526,7 @@ static void draw_extra_seqinfo(void)
/* NAME */
glRasterPos3f(xco, 0.3, 0.0);
strcpy(str, give_seqname(last_seq));
strncpy(str, give_seqname(last_seq), 255);
BMF_DrawString(G.font, str);
xco += xfac*BMF_GetStringWidth(G.font, str) +30.0*xfac;
@@ -710,8 +710,8 @@ static void seq_panel_properties(short cntrl) // SEQ_HANDLER_PROPERTIES
if(last_seq->type==SEQ_WIPE){
WipeVars *wipe = (WipeVars *)last_seq->effectdata;
char formatstring[1024];
strcpy(formatstring, "Transition Type %t|Single Wipe%x0|Double Wipe %x1|Iris Wipe %x4|Clock Wipe %x5");
char formatstring[256];
strncpy(formatstring, "Transition Type %t|Single Wipe%x0|Double Wipe %x1|Iris Wipe %x4|Clock Wipe %x5", 255);
uiDefButS(block, MENU,SEQ_BUT_EFFECT, formatstring, 10,90,220,22, &wipe->wipetype, 0, 0, 0, 0, "What type of wipe should be performed");
uiDefButF(block, NUM,SEQ_BUT_EFFECT,"Blur:", 10,65,220,22, &wipe->edgeWidth,0.0,1.0, 1, 2, "The percent width of the blur edge");
switch(wipe->wipetype){ /*Skip Types that do not require angle*/

View File

@@ -95,8 +95,8 @@
#include "mydevice.h"
Sequence *last_seq=0;
char last_imagename[80]= "/";
char last_sounddir[80]= "";
char last_imagename[FILE_MAXDIR+FILE_MAXFILE]= "/";
char last_sounddir[FILE_MAXDIR+FILE_MAXFILE]= "";
/* void transform_seq(int mode); already in BIF_editseq.h */
@@ -382,12 +382,12 @@ void mouse_select_seq(void)
if ((seq->type == SEQ_IMAGE) || (seq->type == SEQ_MOVIE)) {
if(seq->strip) {
strcpy(last_imagename, seq->strip->dir);
strncpy(last_imagename, seq->strip->dir, FILE_MAXDIR-1);
}
} else
if (seq->type == SEQ_SOUND) {
if(seq->strip) {
strcpy(last_sounddir, seq->strip->dir);
strncpy(last_sounddir, seq->strip->dir, FILE_MAXDIR-1);
}
}
@@ -486,13 +486,13 @@ static Sequence *sfile_to_sequence(SpaceFile *sfile, int cfra, int machine, int
seq->strip= strip= MEM_callocN(sizeof(Strip), "strip");
strip->len= totsel;
strip->us= 1;
strcpy(strip->dir, sfile->dir);
strncpy(strip->dir, sfile->dir, FILE_MAXDIR-1);
strip->stripdata= se= MEM_callocN(totsel*sizeof(StripElem), "stripelem");
for(a=0; a<sfile->totfile; a++) {
if(sfile->filelist[a].flags & ACTIVE) {
if( (sfile->filelist[a].type & S_IFDIR)==0 ) {
strcpy(se->name, sfile->filelist[a].relname);
strncpy(se->name, sfile->filelist[a].relname, FILE_MAXFILE-1);
se->ok= 1;
se++;
}
@@ -500,12 +500,12 @@ static Sequence *sfile_to_sequence(SpaceFile *sfile, int cfra, int machine, int
}
/* no selected file: */
if(totsel==1 && se==strip->stripdata) {
strcpy(se->name, sfile->file);
strncpy(se->name, sfile->file, FILE_MAXFILE-1);
se->ok= 1;
}
/* last active name */
strcpy(last_imagename, seq->strip->dir);
strncpy(last_imagename, seq->strip->dir, FILE_MAXDIR-1);
return seq;
}
@@ -517,12 +517,12 @@ static void sfile_to_mv_sequence(SpaceFile *sfile, int cfra, int machine)
Strip *strip;
StripElem *se;
int totframe, a;
char str[256];
char str[FILE_MAXDIR+FILE_MAXFILE];
totframe= 0;
strcpy(str, sfile->dir);
strcat(str, sfile->file);
strncpy(str, sfile->dir, FILE_MAXDIR-1);
strncat(str, sfile->file, FILE_MAXDIR-1);
/* is it a movie? */
anim = openanim(str, IB_rect);
@@ -545,11 +545,11 @@ static void sfile_to_mv_sequence(SpaceFile *sfile, int cfra, int machine)
seq->strip= strip= MEM_callocN(sizeof(Strip), "strip");
strip->len= totframe;
strip->us= 1;
strcpy(strip->dir, sfile->dir);
strncpy(strip->dir, sfile->dir, FILE_MAXDIR-1);
strip->stripdata= se= MEM_callocN(totframe*sizeof(StripElem), "stripelem");
/* name movie in first strip */
strcpy(se->name, sfile->file);
strncpy(se->name, sfile->file, FILE_MAXFILE-1);
for(a=1; a<=totframe; a++, se++) {
se->ok= 1;
@@ -557,7 +557,7 @@ static void sfile_to_mv_sequence(SpaceFile *sfile, int cfra, int machine)
}
/* last active name */
strcpy(last_imagename, seq->strip->dir);
strncpy(last_imagename, seq->strip->dir, FILE_MAXDIR-1);
}
static Sequence *sfile_to_snd_sequence(SpaceFile *sfile, int cfra, int machine)
@@ -572,8 +572,8 @@ static Sequence *sfile_to_snd_sequence(SpaceFile *sfile, int cfra, int machine)
totframe= 0.0;
strcpy(str, sfile->dir);
strcat(str, sfile->file);
strncpy(str, sfile->dir, FILE_MAXDIR-1);
strncat(str, sfile->file, FILE_MAXFILE-1);
sound= sound_new_sound(str);
if (!sound || sound->sample->type == SAMPLE_INVALID) {
@@ -602,11 +602,11 @@ static Sequence *sfile_to_snd_sequence(SpaceFile *sfile, int cfra, int machine)
seq->strip= strip= MEM_callocN(sizeof(Strip), "strip");
strip->len= totframe;
strip->us= 1;
strcpy(strip->dir, sfile->dir);
strncpy(strip->dir, sfile->dir, FILE_MAXDIR-1);
strip->stripdata= se= MEM_callocN(totframe*sizeof(StripElem), "stripelem");
/* name sound in first strip */
strcpy(se->name, sfile->file);
strncpy(se->name, sfile->file, FILE_MAXFILE-1);
for(a=1; a<=totframe; a++, se++) {
se->ok= 2; /* why? */
@@ -615,7 +615,7 @@ static Sequence *sfile_to_snd_sequence(SpaceFile *sfile, int cfra, int machine)
}
/* last active name */
strcpy(last_sounddir, seq->strip->dir);
strncpy(last_sounddir, seq->strip->dir, FILE_MAXDIR-1);
return seq;
}
@@ -655,7 +655,7 @@ static void add_image_strips(char *name)
for(a=0; a<totfile; a++) {
if(files[a].flags & ACTIVE) {
if( (files[a].type & S_IFDIR) ) {
strcat(sfile->dir, files[a].relname);
strncat(sfile->dir, files[a].relname, FILE_MAXFILE-1);
strcat(sfile->dir,"/");
read_dir(sfile);
@@ -1113,7 +1113,7 @@ void add_sequence(int type)
break;
case 103:
if (!last_sounddir[0]) strcpy(last_sounddir, U.sounddir);
if (!last_sounddir[0]) strncpy(last_sounddir, U.sounddir, FILE_MAXDIR-1);
activate_fileselect(FILE_SPECIAL, "Select Wav", last_sounddir, add_sound_strip);
break;
}

View File

@@ -1654,8 +1654,10 @@ static int ui_do_but_NUM(uiBut *but)
temp= floor(tempf+.5);
if(tempf==but->min || tempf==but->max);
else if(qual & LR_CTRLKEY) temp= 10*(temp/10);
else if(qual & LR_CTRLKEY) {
if(qual & LR_SHIFTKEY) temp= 100*(temp/100);
else temp= 10*(temp/10);
}
if( temp>=but->min && temp<=but->max) {
value= ui_get_but_val(but);
@@ -1676,10 +1678,18 @@ static int ui_do_but_NUM(uiBut *but)
else {
temp= 0;
if(qual & LR_CTRLKEY) {
if(tempf==but->min || tempf==but->max);
else if(but->max-but->min < 2.10) tempf= 0.1*floor(10*tempf);
else if(but->max-but->min < 21.0) tempf= floor(tempf);
else tempf= 10.0*floor(tempf/10.0);
if(qual & LR_SHIFTKEY) {
if(tempf==but->min || tempf==but->max);
else if(but->max-but->min < 2.10) tempf= 0.01*floor(100.0*tempf);
else if(but->max-but->min < 21.0) tempf= 0.1*floor(10.0*tempf);
else tempf= floor(tempf);
}
else {
if(tempf==but->min || tempf==but->max);
else if(but->max-but->min < 2.10) tempf= 0.1*floor(10*tempf);
else if(but->max-but->min < 21.0) tempf= floor(tempf);
else tempf= 10.0*floor(tempf/10.0);
}
}
if( tempf>=but->min && tempf<=but->max) {
@@ -1947,9 +1957,17 @@ static int ui_do_but_SLI(uiBut *but)
if(tempf==but->min || tempf==but->max);
else if( but->pointype==FLO ) {
if(but->max-but->min < 2.10) tempf= 0.1*floor(10*tempf);
else if(but->max-but->min < 21.0) tempf= floor(tempf);
else tempf= 10.0*floor(tempf/10.0);
if(qual & LR_SHIFTKEY) {
if(tempf==but->min || tempf==but->max);
else if(but->max-but->min < 2.10) tempf= 0.01*floor(100.0*tempf);
else if(but->max-but->min < 21.0) tempf= 0.1*floor(10.0*tempf);
else tempf= floor(tempf);
}
else {
if(but->max-but->min < 2.10) tempf= 0.1*floor(10*tempf);
else if(but->max-but->min < 21.0) tempf= floor(tempf);
else tempf= 10.0*floor(tempf/10.0);
}
}
else {
temp= 10*(temp/10);

View File

@@ -129,7 +129,7 @@ void open_plugin_seq(PluginSeq *pis, char *seqname)
MEM_freeN(info);
cp= PIL_dynlib_find_symbol(pis->handle, "seqname");
if(cp) strcpy(cp, seqname);
if(cp) strncpy(cp, seqname, 21);
} else {
printf ("Plugin returned unrecognized version number\n");
return;
@@ -146,7 +146,7 @@ PluginSeq *add_plugin_seq(char *str, char *seqname)
pis= MEM_callocN(sizeof(PluginSeq), "PluginSeq");
strcpy(pis->name, str);
strncpy(pis->name, str, FILE_MAXDIR+FILE_MAXFILE);
open_plugin_seq(pis, seqname);
if(pis->doit==0) {
@@ -1647,7 +1647,7 @@ void do_effect(int cfra, Sequence *seq, StripElem *se)
if(seq->plugin->cfra) *(seq->plugin->cfra)= frame_to_float(CFRA);
cp= PIL_dynlib_find_symbol(seq->plugin->handle, "seqname");
if(cp) strcpy(cp, seq->name+2);
if(cp) strncpy(cp, seq->name+2, 22);
if (seq->plugin->version<=2) {
if(se1->ibuf) IMB_convert_rgba_to_abgr(se1->ibuf->x*se1->ibuf->y, se1->ibuf->rect);
@@ -1800,7 +1800,7 @@ void do_build_seqar_cfra(ListBase *seqbase, Sequence ***seqar, int cfra)
Scene *oldsce;
unsigned int *rectot;
int oldx, oldy, oldcfra, doseq;
char name[FILE_MAXDIR];
char name[FILE_MAXDIR+FILE_MAXFILE];
if(seqar==NULL) return;
@@ -1886,8 +1886,8 @@ void do_build_seqar_cfra(ListBase *seqbase, Sequence ***seqar, int cfra)
/* if playanim or render: no waitcursor */
if((G.f & G_PLAYANIM)==0) waitcursor(1);
strcpy(name, seq->strip->dir);
strcat(name, se->name);
strncpy(name, seq->strip->dir, FILE_MAXDIR-1);
strncat(name, se->name, FILE_MAXFILE);
BLI_convertstringcode(name, G.sce, G.scene->r.cfra);
se->ibuf= IMB_loadiffname(name, IB_rect);
@@ -1913,8 +1913,8 @@ void do_build_seqar_cfra(ListBase *seqbase, Sequence ***seqar, int cfra)
if((G.f & G_PLAYANIM)==0) waitcursor(1);
if(seq->anim==0) {
strcpy(name, seq->strip->dir);
strcat(name, seq->strip->stripdata->name);
strncpy(name, seq->strip->dir, FILE_MAXDIR-1);
strncat(name, seq->strip->stripdata->name, FILE_MAXFILE-1);
BLI_convertstringcode(name, G.sce, G.scene->r.cfra);
seq->anim = openanim(name, IB_rect);

View File

@@ -1998,7 +1998,7 @@ int Resize(TransInfo *t, short mval[2])
/* for manipulator, center handle, the scaling can't be done relative to center */
if( (t->flag & T_USES_MANIPULATOR) && t->con.mode==0) {
ratio = 1.0f - ((t->center2d[0] - mval[0]) + (t->center2d[1] - mval[1]))/100.0f;
ratio = 1.0f - ((t->imval[0] - mval[0]) + (t->imval[1] - mval[1]))/100.0f;
}
else {
ratio = (float)sqrt( (float)