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.
This commit is contained in:
2010-03-06 18:21:57 +00:00
parent c846136cd0
commit c0f56503bf
4 changed files with 25 additions and 22 deletions

View File

@@ -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

View File

@@ -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;
/* if result > 21, strncpy don't put the final '\0' to name. */
if( result >= 21 ) name[21]= 0;
strncpy(name, tname, sizeof(name)-1);
result = check_for_dupid( lb, id, name );
strcpy( id->name+2, name );
/* 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(name[0] == '\0')
strcpy(name, ID_FALLBACK_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) );

View File

@@ -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();

View File

@@ -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);