minor edits

- remove unneeded type check from convert grease pencil operator.
- correct some error prints & use __func__.
- make copy_libblock take an ID* argument rather than void*.
This commit is contained in:
2011-11-07 04:36:37 +00:00
parent 96d73bfdcf
commit bb8fe0bf4a
23 changed files with 46 additions and 52 deletions

View File

@@ -46,7 +46,7 @@ struct PointerRNA;
struct PropertyRNA;
void *alloc_libblock(struct ListBase *lb, short type, const char *name);
void *copy_libblock(void *rt);
void *copy_libblock(struct ID *id);
void copy_libblock_data(struct ID *id, const struct ID *id_from, const short do_action);
void BKE_id_lib_local_paths(struct Main *bmain, struct ID *id);

View File

@@ -185,7 +185,7 @@ bAction *copy_action (bAction *src)
if (src == NULL)
return NULL;
dst= copy_libblock(src);
dst= copy_libblock(&src->id);
/* duplicate the lists of groups and markers */
BLI_duplicatelist(&dst->groups, &src->groups);

View File

@@ -204,7 +204,7 @@ bArmature *copy_armature(bArmature *arm)
Bone *oldBone, *newBone;
Bone *newActBone= NULL;
newArm= copy_libblock (arm);
newArm= copy_libblock(&arm->id);
BLI_duplicatelist(&newArm->bonebase, &arm->bonebase);
/* Duplicate the childrens' lists*/

View File

@@ -144,7 +144,7 @@ Brush *copy_brush(Brush *brush)
{
Brush *brushn;
brushn= copy_libblock(brush);
brushn= copy_libblock(&brush->id);
if (brush->mtex.tex)
id_us_plus((ID*)brush->mtex.tex);

View File

@@ -68,7 +68,7 @@ Camera *copy_camera(Camera *cam)
{
Camera *camn;
camn= copy_libblock(cam);
camn= copy_libblock(&cam->id);
return camn;
}

View File

@@ -192,7 +192,7 @@ Curve *copy_curve(Curve *cu)
Curve *cun;
int a;
cun= copy_libblock(cu);
cun= copy_libblock(&cu->id);
cun->nurb.first= cun->nurb.last= NULL;
duplicateNurblist( &(cun->nurb), &(cu->nurb));

View File

@@ -154,7 +154,7 @@ Key *copy_key(Key *key)
if(key==NULL) return NULL;
keyn= copy_libblock(key);
keyn= copy_libblock(&key->id);
BLI_duplicatelist(&keyn->block, &key->block);

View File

@@ -106,7 +106,7 @@ Lamp *copy_lamp(Lamp *la)
Lamp *lan;
int a;
lan= copy_libblock(la);
lan= copy_libblock(&la->id);
for(a=0; a<MAX_MTEX; a++) {
if(lan->mtex[a]) {
@@ -132,7 +132,7 @@ Lamp *localize_lamp(Lamp *la)
Lamp *lan;
int a;
lan= copy_libblock(la);
lan= copy_libblock(&la->id);
BLI_remlink(&G.main->lamp, lan);
for(a=0; a<MAX_MTEX; a++) {

View File

@@ -204,7 +204,7 @@ Lattice *copy_lattice(Lattice *lt)
{
Lattice *ltn;
ltn= copy_libblock(lt);
ltn= copy_libblock(&lt->id);
ltn->def= MEM_dupallocN(lt->def);
ltn->key= copy_key(ltn->key);

View File

@@ -717,14 +717,11 @@ void copy_libblock_data(ID *id, const ID *id_from, const short do_action)
}
/* used everywhere in blenkernel */
void *copy_libblock(void *rt)
void *copy_libblock(ID *id)
{
ID *idn, *id;
ID *idn;
ListBase *lb;
char *cp, *cpn;
size_t idn_len;
id= rt;
lb= which_libbase(G.main, GS(id->name));
idn= alloc_libblock(lb, GS(id->name), id->name+2);
@@ -733,8 +730,9 @@ void *copy_libblock(void *rt)
idn_len= MEM_allocN_len(idn);
if((int)idn_len - (int)sizeof(ID) > 0) { /* signed to allow neg result */
cp= (char *)id;
cpn= (char *)idn;
const char *cp= (const char *)id;
char *cpn= (char *)idn;
memcpy(cpn+sizeof(ID), cp+sizeof(ID), idn_len - sizeof(ID));
}

View File

@@ -215,7 +215,7 @@ Material *copy_material(Material *ma)
Material *man;
int a;
man= copy_libblock(ma);
man= copy_libblock(&ma->id);
id_lib_extern((ID *)man->group);
@@ -247,7 +247,7 @@ Material *localize_material(Material *ma)
Material *man;
int a;
man= copy_libblock(ma);
man= copy_libblock(&ma->id);
BLI_remlink(&G.main->mat, man);
/* no increment for texture ID users, in previewrender.c it prevents decrement */

View File

@@ -120,7 +120,7 @@ MetaBall *copy_mball(MetaBall *mb)
MetaBall *mbn;
int a;
mbn= copy_libblock(mb);
mbn= copy_libblock(&mb->id);
BLI_duplicatelist(&mbn->elems, &mb->elems);

View File

@@ -206,7 +206,7 @@ Mesh *copy_mesh(Mesh *me)
MTFace *tface;
int a, i;
men= copy_libblock(me);
men= copy_libblock(&me->id);
men->mat= MEM_dupallocN(me->mat);
for(a=0; a<men->totcol; a++) {

View File

@@ -629,7 +629,7 @@ bNodeTree *ntreeCopyTree(bNodeTree *ntree)
for(newtree=G.main->nodetree.first; newtree; newtree= newtree->id.next)
if(newtree==ntree) break;
if(newtree) {
newtree= copy_libblock(ntree);
newtree= copy_libblock(&ntree->id);
} else {
newtree= MEM_dupallocN(ntree);
copy_libblock_data(&newtree->id, &ntree->id, TRUE); /* copy animdata and ID props */

View File

@@ -1084,7 +1084,7 @@ Object *copy_object(Object *ob)
ModifierData *md;
int a;
obn= copy_libblock(ob);
obn= copy_libblock(&ob->id);
if(ob->totcol) {
obn->mat= MEM_dupallocN(ob->mat);

View File

@@ -3569,7 +3569,7 @@ ParticleSettings *psys_copy_settings(ParticleSettings *part)
ParticleSettings *partn;
int a;
partn= copy_libblock(part);
partn= copy_libblock(&part->id);
partn->pd= MEM_dupallocN(part->pd);
partn->pd2= MEM_dupallocN(part->pd2);
partn->effector_weights= MEM_dupallocN(part->effector_weights);

View File

@@ -126,7 +126,7 @@ Scene *copy_scene(Scene *sce, int type)
scen->r.layers= lb;
}
else {
scen= copy_libblock(sce);
scen= copy_libblock(&sce->id);
BLI_duplicatelist(&(scen->base), &(sce->base));
clear_id_newpoins();

View File

@@ -69,7 +69,7 @@ Speaker *copy_speaker(Speaker *spk)
{
Speaker *spkn;
spkn= copy_libblock(spk);
spkn= copy_libblock(&spk->id);
if(spkn->sound)
spkn->sound->id.us++;

View File

@@ -431,7 +431,7 @@ Text *copy_text(Text *ta)
Text *tan;
TextLine *line, *tmp;
tan= copy_libblock(ta);
tan= copy_libblock(&ta->id);
/* file name can be NULL */
if(ta->name) {

View File

@@ -751,7 +751,7 @@ Tex *copy_texture(Tex *tex)
{
Tex *texn;
texn= copy_libblock(tex);
texn= copy_libblock(&tex->id);
if(texn->type==TEX_IMAGE) id_us_plus((ID *)texn->ima);
else texn->ima= NULL;
@@ -781,7 +781,7 @@ Tex *localize_texture(Tex *tex)
{
Tex *texn;
texn= copy_libblock(tex);
texn= copy_libblock(&tex->id);
BLI_remlink(&G.main->tex, texn);
/* image texture: free_texture also doesn't decrease */

View File

@@ -118,7 +118,7 @@ World *copy_world(World *wrld)
World *wrldn;
int a;
wrldn= copy_libblock(wrld);
wrldn= copy_libblock(&wrld->id);
for(a=0; a<MAX_MTEX; a++) {
if(wrld->mtex[a]) {
@@ -142,7 +142,7 @@ World *localize_world(World *wrld)
World *wrldn;
int a;
wrldn= copy_libblock(wrld);
wrldn= copy_libblock(&wrld->id);
BLI_remlink(&G.main->world, wrldn);
for(a=0; a<MAX_MTEX; a++) {

View File

@@ -555,8 +555,8 @@ static void gp_layer_to_curve (bContext *C, bGPdata *gpd, bGPDlayer *gpl, short
* - must clear transforms set on object, as those skew our results
*/
ob= add_object(scene, OB_CURVE);
ob->loc[0]= ob->loc[1]= ob->loc[2]= 0;
ob->rot[0]= ob->rot[1]= ob->rot[2]= 0;
zero_v3(ob->loc);
zero_v3(ob->rot);
cu= ob->data;
cu->flag |= CU_3D;
@@ -573,6 +573,9 @@ static void gp_layer_to_curve (bContext *C, bGPdata *gpd, bGPDlayer *gpl, short
case GP_STROKECONVERT_CURVE:
gp_stroke_to_bezier(C, gpl, gps, cu, subrect_ptr);
break;
default:
BLI_assert(!"invalid mode");
break;
}
}
}
@@ -602,17 +605,7 @@ static int gp_convert_layer_exec (bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
/* handle conversion modes */
switch (mode) {
case GP_STROKECONVERT_PATH:
case GP_STROKECONVERT_CURVE:
gp_layer_to_curve(C, gpd, gpl, mode);
break;
default: /* unsupoorted */
BKE_report(op->reports, RPT_ERROR, "Unknown conversion option");
return OPERATOR_CANCELLED;
}
gp_layer_to_curve(C, gpd, gpl, mode);
/* notifiers */
WM_event_add_notifier(C, NC_OBJECT|NA_ADDED, NULL);

View File

@@ -270,7 +270,7 @@ static int wm_macro_modal(bContext *C, wmOperator *op, wmEvent *event)
int retval= OPERATOR_FINISHED;
if(opm==NULL)
printf("macro error, calling NULL modal()\n");
printf("%s: macro error, calling NULL modal()\n", __func__);
else {
retval = opm->type->modal(C, opm, event);
OPERATOR_RETVAL_CHECK(retval);
@@ -341,7 +341,7 @@ wmOperatorType *WM_operatortype_append_macro(const char *idname, const char *nam
wmOperatorType *ot;
if(WM_operatortype_find(idname, TRUE)) {
printf("Macro error: operator %s exists\n", idname);
printf("%s: macro error: operator %s exists\n", __func__, idname);
return NULL;
}
@@ -658,10 +658,11 @@ int WM_menu_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event))
uiLayout *layout;
if(prop==NULL) {
printf("WM_menu_invoke: %s has no enum property set\n", op->type->idname);
printf("%s: %s has no enum property set\n", __func__, op->type->idname);
}
else if (RNA_property_type(prop) != PROP_ENUM) {
printf("WM_menu_invoke: %s \"%s\" is not an enum property\n", op->type->idname, RNA_property_identifier(prop));
printf("%s: %s \"%s\" is not an enum property\n",
__func__, op->type->idname, RNA_property_identifier(prop));
}
else if (RNA_property_is_set(op->ptr, RNA_property_identifier(prop))) {
const int retval= op->type->exec(C, op);
@@ -686,10 +687,12 @@ static void operator_enum_search_cb(const struct bContext *C, void *arg_ot, cons
PropertyRNA *prop= ot->prop;
if(prop==NULL) {
printf("WM_enum_search_invoke: %s has no enum property set\n", ot->idname);
printf("%s: %s has no enum property set\n",
__func__, ot->idname);
}
else if (RNA_property_type(prop) != PROP_ENUM) {
printf("WM_enum_search_invoke: %s \"%s\" is not an enum property\n", ot->idname, RNA_property_identifier(prop));
printf("%s: %s \"%s\" is not an enum property\n",
__func__, ot->idname, RNA_property_identifier(prop));
}
else {
PointerRNA ptr;
@@ -725,7 +728,7 @@ static void operator_enum_call_cb(struct bContext *C, void *arg1, void *arg2)
WM_operator_properties_free(&props_ptr);
}
else {
printf("operator_enum_call_cb: op->prop for '%s' is NULL\n", ot->idname);
printf("%s: op->prop for '%s' is NULL\n", __func__, ot->idname);
}
}
}
@@ -2619,7 +2622,7 @@ int WM_gesture_lasso_modal(bContext *C, wmOperator *op, wmEvent *event)
memcpy(gesture->customdata, old_lasso, 2*sizeof(short)*gesture->size);
gesture->size = gesture->size + WM_LASSO_MIN_POINTS;
MEM_freeN(old_lasso);
printf("realloc\n");
// printf("realloc\n");
}
{