minor edits
authorCampbell Barton <ideasman42@gmail.com>
Mon, 7 Nov 2011 04:36:37 +0000 (04:36 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Mon, 7 Nov 2011 04:36:37 +0000 (04:36 +0000)
- 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*.

23 files changed:
source/blender/blenkernel/BKE_library.h
source/blender/blenkernel/intern/action.c
source/blender/blenkernel/intern/armature.c
source/blender/blenkernel/intern/brush.c
source/blender/blenkernel/intern/camera.c
source/blender/blenkernel/intern/curve.c
source/blender/blenkernel/intern/key.c
source/blender/blenkernel/intern/lamp.c
source/blender/blenkernel/intern/lattice.c
source/blender/blenkernel/intern/library.c
source/blender/blenkernel/intern/material.c
source/blender/blenkernel/intern/mball.c
source/blender/blenkernel/intern/mesh.c
source/blender/blenkernel/intern/node.c
source/blender/blenkernel/intern/object.c
source/blender/blenkernel/intern/particle.c
source/blender/blenkernel/intern/scene.c
source/blender/blenkernel/intern/speaker.c
source/blender/blenkernel/intern/text.c
source/blender/blenkernel/intern/texture.c
source/blender/blenkernel/intern/world.c
source/blender/editors/gpencil/gpencil_edit.c
source/blender/windowmanager/intern/wm_operators.c

index 9130cac6cd60f2feaa86769ef8e094db148627b9..308d7ff22c2633043ee0d7ed90812b7fd3b99355 100644 (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);
index 944f7c6a0b627a3bda5ee895088d3d8c4bbee338..5fb03b7bbd00dd5199269a88ce1fc9b36ab3375a 100644 (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);
index f19ed859064e313106cee8780e79a8d9a0ce4519..50f305e440012eab2c8e153a5a294d504eead48c 100644 (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*/
index e78b89441c908037af9a451f66c64d3bcb92c0ef..09021e71025f8ab0a2ab9a54b7c8bba5335b93e6 100644 (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);
index eeec82c3beb79d321d1b60ef6fc9adb47f79b4cc..145eb9363e9b8e7a463e08030e47c68a975214aa 100644 (file)
@@ -68,7 +68,7 @@ Camera *copy_camera(Camera *cam)
 {
        Camera *camn;
        
-       camn= copy_libblock(cam);
+       camn= copy_libblock(&cam->id);
        
        return camn;
 }
index adc08f5cd9f76553ce1c6475862c9ce85f436c6c..160f5703a01b85e2f5580c2027c26c94e379cb9a 100644 (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));
 
index c389800b0d1385279da9c72be2e0b692a0efac53..eb7d07a6f7de1f26f6af7b4851f2cd4b7a8d0a5a 100644 (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);
        
index 974aa660e9fe7a04cabc31de89885660217aa32f..4edd032dc0445815cad306dd633a239f5b137166 100644 (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++) {
index cef23ac38242fbebdddb02b89ef8fb7e8cd8ba01..7c9e2be4493befd2d73f3a32d4c2866f41bd0441 100644 (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);
index 0b01c3d6dd1b4af0475d5c763da391d070080ab7..878b87759b7b018f6386dd5df75a55784b755136 100644 (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));
        }
        
index 7be3514e0f2733792168907530cc092512452e58..48c6d6b2a19313efa95a663d77382fe6ffe40866 100644 (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 */
index 327306b32eed899a465ea75c5cb3bb13fc8a5b38..5c82acde99b1bef4d37a3e512acf0ff80d599abd 100644 (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);
        
index 4a8bc34cdf762002ec760a0c8072725d4532f6f0..ec9d4873057664e02f525b319b59db542d410359 100644 (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++) {
index 8f60929135103cb934248755f4bc3f294b6673c1..a9b2ffe7529c3fade47d5bd0131dc74d7c51cfe1 100644 (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 */
index ae4e6ea81b82fbe7fc27262a83df024ce28b6e71..1d65483996946d128e17cf79aad6a0a505232373 100644 (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);
index 56e4c91ba5e56b6429f450d89896aa0f07a2ae42..1064a5af1609d39458a8b1d9e186f4ccdbffb83a 100644 (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);
index 66d29b02263e4e9372f24c5c54f37814bb4a64b8..14dfe015894c5d5f8b18b3cc58347e989d1cc926 100644 (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();
index 018c7a197ffdb701c8d3b174ae0a6b49dac5f7ee..a14233e9179ff7b6410b7fb6f80af97421cb3ca9 100644 (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++;
 
index 955127a8000667e9497a84c9251030295c3ef9a7..e8be0bb2608f069527960c43f3a1d7cf09edfe92 100644 (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) {
index 3aa289d0ef8bd72add873931dfc47d20f15d6710..377eeef117e6114cb1fcb15629de4651b0275a16 100644 (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 */
index c7d2763774d83fc65467dace6da0e235f515eca3..1d6972b9d611cafe8771a1378fdd2c6bb4666cfa 100644 (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++) {
index d481be94bcc8d1e64d82f62edaa6d1d3d2863b27..7b79384fbb499618d956bac426cd0f3a51f3da12 100644 (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);
index 933066513e2e379e33a366503dcedcd12d6d6b0b..19e9a6bd48335db073921c7a120c03edad03b92c 100644 (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");
                        }
 
                        {