diff options
author | Campbell Barton <ideasman42@gmail.com> | 2010-03-06 21:21:57 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2010-03-06 21:21:57 +0300 |
commit | c0f56503bf6fcd92a65a8b05466c5093e083c96a (patch) | |
tree | 58d4692d5a25dbcd1af5779a075c2caf5b49679f /source/blender | |
parent | c846136cd01e16c11fb42caf5b9ceaef41e3c64c (diff) |
disallow naming ID datablocks an empty string, this wont work, you cant select them in the ID user input and it can mess up writing files based on names.
also fixed some warnings.
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/blenkernel/BKE_library.h | 4 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/library.c | 37 | ||||
-rw-r--r-- | source/blender/editors/screen/screendump.c | 2 | ||||
-rw-r--r-- | source/blender/editors/sculpt_paint/sculpt.c | 4 |
4 files changed, 25 insertions, 22 deletions
diff --git a/source/blender/blenkernel/BKE_library.h b/source/blender/blenkernel/BKE_library.h index b859dbe6f51..454666566dc 100644 --- a/source/blender/blenkernel/BKE_library.h +++ b/source/blender/blenkernel/BKE_library.h @@ -51,7 +51,6 @@ int id_make_local(struct ID *id, int test); int id_copy(struct ID *id, struct ID **newid, int test); int id_unlink(struct ID *id, int test); -int check_for_dupid(struct ListBase *lb, struct ID *id, char *name); int new_id(struct ListBase *lb, struct ID *id, const char *name); struct ListBase *wich_libbase(struct Main *mainlib, short type); @@ -82,5 +81,8 @@ void recalc_all_library_objects(struct Main *main); void set_free_windowmanager_cb(void (*func)(struct bContext *, struct wmWindowManager *) ); +/* use when "" is given to new_id() */ +#define ID_FALLBACK_NAME "Untitled" + #endif diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c index 3ea36450b80..79bc92bdbfb 100644 --- a/source/blender/blenkernel/intern/library.c +++ b/source/blender/blenkernel/intern/library.c @@ -1093,15 +1093,16 @@ static ID *is_dupid(ListBase *lb, ID *id, char *name) * id is NULL; */ -int check_for_dupid(ListBase *lb, ID *id, char *name) +static int check_for_dupid(ListBase *lb, ID *id, char *name) { ID *idtest; int nr= 0, nrtest, a; const int maxtest=32; char left[32], leftest[32], in_use[32]; - + /* make sure input name is terminated properly */ - if( strlen(name) > 21 ) name[21]= 0; + /* if( strlen(name) > 21 ) name[21]= 0; */ + /* removed since this is only ever called from one place - campbell */ while (1) { @@ -1184,27 +1185,29 @@ int new_id(ListBase *lb, ID *id, const char *tname) { int result; char name[22]; - + /* if library, don't rename */ if(id->lib) return 0; /* if no libdata given, look up based on ID */ if(lb==NULL) lb= wich_libbase(G.main, GS(id->name)); - if(tname==0) { /* if no name given, use name of current ID */ - strncpy(name, id->name+2, 21); - result= strlen(id->name+2); - } - else { /* else make a copy (tname args can be const) */ - strncpy(name, tname, 21); - result= strlen(tname); - } + /* if no name given, use name of current ID + * else make a copy (tname args can be const) */ + if(tname==NULL) + tname= id->name+2; + + strncpy(name, tname, sizeof(name)-1); + + /* if result > 21, strncpy don't put the final '\0' to name. + * easier to assign each time then to check if its needed */ + name[sizeof(name)-1]= 0; - /* if result > 21, strncpy don't put the final '\0' to name. */ - if( result >= 21 ) name[21]= 0; + if(name[0] == '\0') + strcpy(name, ID_FALLBACK_NAME); - result = check_for_dupid( lb, id, name ); - strcpy( id->name+2, name ); + result = check_for_dupid(lb, id, name); + strcpy(id->name+2, name); /* This was in 2.43 and previous releases * however all data in blender should be sorted, not just duplicate names @@ -1393,7 +1396,7 @@ void text_idbutton(struct ID *id, char *text) void rename_id(ID *id, char *name) { ListBase *lb; - + strncpy(id->name+2, name, 21); lb= wich_libbase(G.main, GS(id->name) ); diff --git a/source/blender/editors/screen/screendump.c b/source/blender/editors/screen/screendump.c index d34a562f894..4427155885d 100644 --- a/source/blender/editors/screen/screendump.c +++ b/source/blender/editors/screen/screendump.c @@ -126,7 +126,7 @@ static unsigned int *screenshot(bContext *C, int *dumpsx, int *dumpsy, int fscre if (*dumpsx && *dumpsy) { - dumprect= MEM_mallocN(sizeof(int) * dumpsx[0] * dumpsy[0], "dumprect"); + dumprect= MEM_mallocN(sizeof(int) * (*dumpsx) * (*dumpsy), "dumprect"); glReadBuffer(GL_FRONT); glReadPixels(x, y, *dumpsx, *dumpsy, GL_RGBA, GL_UNSIGNED_BYTE, dumprect); glFinish(); diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c index 051f72b2239..3221dbc8994 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -252,9 +252,7 @@ void sculpt_get_redraw_planes(float planes[4][4], ARegion *ar, #endif view3d_calculate_clipping(bb, planes, &mats, &rect); - - for(i = 0; i < 16; ++i) - ((float*)planes)[i] = -((float*)planes)[i]; + mul_m4_fl(planes, -1.0f); MEM_freeN(bb); |