Cleaned up some printfs in editors/ - converted some to reports, hid others behind...
authorMatt Ebb <matt@mke3.net>
Fri, 22 Jan 2010 06:48:29 +0000 (06:48 +0000)
committerMatt Ebb <matt@mke3.net>
Fri, 22 Jan 2010 06:48:29 +0000 (06:48 +0000)
22 files changed:
source/blender/editors/animation/keyframing.c
source/blender/editors/armature/editarmature.c
source/blender/editors/armature/poselib.c
source/blender/editors/curve/editcurve.c
source/blender/editors/interface/interface_handlers.c
source/blender/editors/interface/interface_icons.c
source/blender/editors/interface/interface_style.c
source/blender/editors/interface/view2d.c
source/blender/editors/mesh/editmesh_add.c
source/blender/editors/mesh/editmesh_lib.c
source/blender/editors/mesh/editmesh_loop.c
source/blender/editors/object/object_relations.c
source/blender/editors/object/object_vgroup.c
source/blender/editors/physics/particle_object.c
source/blender/editors/screen/area.c
source/blender/editors/screen/screen_edit.c
source/blender/editors/screen/screen_ops.c
source/blender/editors/screen/screendump.c
source/blender/editors/space_image/image_ops.c
source/blender/editors/space_node/node_edit.c
source/blender/editors/space_view3d/view3d_buttons.c
source/blender/editors/space_view3d/view3d_toolbar.c

index 6d8938d9545a804ab8c7b8ce7eafe9b3b3495895..e042d2731fde6cc9931a8505b896a11c581c5161 100644 (file)
@@ -1051,7 +1051,7 @@ static int insert_key_exec (bContext *C, wmOperator *op)
        /* try to insert keyframes for the channels specified by KeyingSet */
        success= modify_keyframes(scene, &dsources, NULL, ks, MODIFYKEY_MODE_INSERT, cfra);
        if (G.f & G_DEBUG)
-               printf("KeyingSet '%s' - Successfully added %d Keyframes \n", ks->name, success);
+               BKE_reportf(op->reports, RPT_INFO, "KeyingSet '%s' - Successfully added %d Keyframes \n", ks->name, success);
        
        /* report failure or do updates? */
        if (success) {
@@ -1320,7 +1320,7 @@ static int delete_key_v3d_exec (bContext *C, wmOperator *op)
                        }
                }
                
-               printf("Ob '%s' - Successfully removed %d keyframes \n", id->name+2, success);
+               BKE_reportf(op->reports, RPT_INFO, "Ob '%s' - Successfully removed %d keyframes \n", id->name+2, success);
                
                ob->recalc |= OB_RECALC_OB;
        }
index cf7cd3e1f27230c153962e041d15c7b8c4829087..8d6fa3ba020dcaa7193706900d2d42259e40dd0b 100644 (file)
@@ -320,7 +320,8 @@ void ED_armature_from_edit(Object *obedit)
                                if (fBone->parent==eBone)
                                        fBone->parent= eBone->parent;
                        }
-                       printf("Warning: removed zero sized bone: %s\n", eBone->name);
+                       if (G.f & G_DEBUG)
+                               printf("Warning: removed zero sized bone: %s\n", eBone->name);
                        bone_free(arm, eBone);
                }
        }
@@ -3006,8 +3007,7 @@ static int armature_fill_bones_exec (bContext *C, wmOperator *op)
        }
        else {
                // FIXME.. figure out a method for multiple bones
-               BKE_report(op->reports, RPT_ERROR, "Too many points selected"); 
-               printf("Points selected: %d \n", count);
+               BKE_reportf(op->reports, RPT_ERROR, "Too many points selected: %d \n", count); 
                BLI_freelistN(&points);
                return OPERATOR_CANCELLED;
        }
@@ -3047,8 +3047,10 @@ static void bones_merge(Object *obedit, EditBone *start, EditBone *end, EditBone
        
        /* check if same bone */
        if (start == end) {
-               printf("Error: same bone! \n");
-               printf("\tstart = %s, end = %s \n", start->name, end->name);
+               if (G.f & G_DEBUG) {
+                       printf("Error: same bone! \n");
+                       printf("\tstart = %s, end = %s \n", start->name, end->name);
+               }
        }
        
        /* step 1: add a new bone
index f4cf907ed4bdb06f0a4b99b3d61bcecde1b4ac80..17d82521a6e556d1f51fab8dbfdd5bc7ca53a1d2 100644 (file)
@@ -1303,7 +1303,8 @@ static void poselib_preview_init_data (bContext *C, wmOperator *op)
                if (pld->act->markers.first) {
                        /* just use first one then... */
                        pld->marker= pld->act->markers.first;
-                       if (pose_index > -2) printf("PoseLib had no active pose\n");
+                       if (pose_index > -2) 
+                               BKE_report(op->reports, RPT_WARNING, "PoseLib had no active pose");
                }
                else {
                        BKE_report(op->reports, RPT_ERROR, "PoseLib has no poses to preview/apply");
index 948448411bfaa891f0e66a4db3773c90816d7e0c..69018b049c24901be6bdff5e6994ed56ab592fe4 100644 (file)
@@ -1004,7 +1004,8 @@ static void adduplicateflagNurb(Object *obedit, short flag)
                                        }
                                }
                                if(newu==0 || newv==0) {
-                                       printf("Can't duplicate Nurb\n");
+                                       if (G.f & G_DEBUG)
+                                               printf("Can't duplicate Nurb\n");
                                }
                                else {
 
index 37d5191691a7d1d479a9bd7bcccf4c7426bb5b32..ab41ac48ff25d29a22d92320bcbc71e6b6bdd8eb 100644 (file)
@@ -684,23 +684,19 @@ static void ui_add_link(uiBut *from, uiBut *to)
        if( (line= ui_is_a_link(from, to)) ) {
                line->flag |= UI_SELECT;
                ui_delete_active_linkline(from->block);
-               printf("already exists, means deletion now\n");
                return;
        }
 
        if (from->type==INLINK && to->type==INLINK) {
-               printf("cannot link\n");
                return;
        }
        else if (from->type==LINK && to->type==INLINK) {
                if( from->link->tocode != (int)to->hardmin ) {
-                       printf("cannot link\n");
                        return;
                }
        }
        else if(from->type==INLINK && to->type==LINK) {
                if( to->link->tocode == (int)from->hardmin ) {
-                       printf("cannot link\n");
                        return;
                }
        }
index 43c8b0b2c74dc2419a346b704719e99e6fa847f1..296b1e3ca57db9290ea496bc96bf0ae56c20e042 100644 (file)
@@ -50,6 +50,7 @@
 #include "DNA_userdef_types.h"
 
 #include "BKE_context.h"
+#include "BKE_global.h"
 #include "BKE_image.h"
 #include "BKE_icons.h"
 #include "BKE_utildefines.h"
@@ -474,7 +475,8 @@ static void init_internal_icons()
                if (BLI_exists(iconfilestr)) {
                        bbuf = IMB_loadiffname(iconfilestr, IB_rect);
                        if(bbuf->x < ICON_IMAGE_W || bbuf->y < ICON_IMAGE_H) {
-                               printf("\n***WARNING***\nIcons file %s too small.\nUsing built-in Icons instead\n", iconfilestr);
+                               if (G.f & G_DEBUG)
+                                       printf("\n***WARNING***\nIcons file %s too small.\nUsing built-in Icons instead\n", iconfilestr);
                                IMB_freeImBuf(bbuf);
                                bbuf= NULL;
                        }
@@ -694,7 +696,8 @@ int UI_icon_get_width(int icon_id)
        icon = BKE_icon_get(icon_id);
        
        if (!icon) {
-               printf("UI_icon_get_width: Internal error, no icon for icon ID: %d\n", icon_id);
+               if (G.f & G_DEBUG)
+                       printf("UI_icon_get_width: Internal error, no icon for icon ID: %d\n", icon_id);
                return 0;
        }
        
@@ -718,7 +721,8 @@ int UI_icon_get_height(int icon_id)
        icon = BKE_icon_get(icon_id);
        
        if (!icon) {
-               printf("UI_icon_get_height: Internal error, no icon for icon ID: %d\n", icon_id);
+               if (G.f & G_DEBUG)
+                       printf("UI_icon_get_height: Internal error, no icon for icon ID: %d\n", icon_id);
                return 0;
        }
        
@@ -757,7 +761,8 @@ static void icon_create_mipmap(struct PreviewImage* prv_img, int miplevel)
        unsigned int size = preview_render_size(miplevel);
 
        if (!prv_img) {
-               printf("Error: requested preview image does not exist");
+               if (G.f & G_DEBUG)
+                       printf("Error: requested preview image does not exist");
        }
        if (!prv_img->rect[miplevel]) {
                prv_img->w[miplevel] = size;
@@ -772,7 +777,8 @@ static void icon_create_mipmap(struct PreviewImage* prv_img, int miplevel)
 static void icon_set_image(bContext *C, ID *id, PreviewImage* prv_img, int miplevel)
 {
        if (!prv_img) {
-               printf("No preview image for this ID: %s\n", id->name);
+               if (G.f & G_DEBUG)
+                       printf("No preview image for this ID: %s\n", id->name);
                return;
        }       
 
@@ -802,13 +808,14 @@ static void icon_draw_rect(float x, float y, int w, int h, float aspect, int rw,
        /* draw */
        if((w<1 || h<1)) {
                // XXX - TODO 2.5 verify whether this case can happen
-               // and only print in debug
-               printf("what the heck! - icons are %i x %i pixels?\n", w, h);
+               if (G.f & G_DEBUG)
+                       printf("what the heck! - icons are %i x %i pixels?\n", w, h);
        }
        /* rect contains image in 'rendersize', we only scale if needed */
        else if(rw!=w && rh!=h) {
                if(w>2000 || h>2000) { /* something has gone wrong! */
-                       printf("insane icon size w=%d h=%d\n",w,h);
+                       if (G.f & G_DEBUG)
+                               printf("insane icon size w=%d h=%d\n",w,h);
                }
                else {
                        ImBuf *ima;
@@ -891,7 +898,8 @@ static void icon_draw_size(float x, float y, int icon_id, float aspect, float al
        icon = BKE_icon_get(icon_id);
        
        if (!icon) {
-               printf("icon_draw_mipmap: Internal error, no icon for icon ID: %d\n", icon_id);
+               if (G.f & G_DEBUG)
+                       printf("icon_draw_mipmap: Internal error, no icon for icon ID: %d\n", icon_id);
                return;
        }
 
index 2e8d2a8cb2b043aa53f8e06c3599ab20d5ec602e..c80db9a1588620a687d029ffb7cf528dc154d617 100644 (file)
@@ -291,8 +291,10 @@ void uiStyleInit(void)
                                font->blf_id= BLF_load_mem("default", (unsigned char*)datatoc_bfont_ttf, datatoc_bfont_ttf_size);
                }
 
-               if (font->blf_id == -1)
-                       printf("uiStyleInit error, no fonts available\n");
+               if (font->blf_id == -1) {
+                       if (G.f & G_DEBUG)
+                               printf("uiStyleInit error, no fonts available\n");
+               }
                else {
                        BLF_set(font->blf_id);
                        /* ? just for speed to initialize?
index cba314b0bf3dcfde18962ddb4472216589261f5c..c5e81e237c9e4a6b5e449368c7716cc91fa648fc 100644 (file)
@@ -838,7 +838,8 @@ void UI_view2d_totRect_set_resize (View2D *v2d, int width, int height, int resiz
                height -= V2D_SCROLL_HEIGHT;
        
        if (ELEM3(0, v2d, width, height)) {
-               printf("Error: View2D totRect set exiting: v2d=%p width=%d height=%d \n", v2d, width, height); // XXX temp debug info
+               if (G.f & G_DEBUG)
+                       printf("Error: View2D totRect set exiting: v2d=%p width=%d height=%d \n", v2d, width, height); // XXX temp debug info
                return;
        }
        
index 1f815aa18fa6bb1f52d906ae0c4c986c51b76017..b79b840eac0672d71e590f49cd42ba8bc180ce92 100644 (file)
@@ -766,7 +766,8 @@ static void addedgeface_mesh(EditMesh *em, wmOperator *op)
                                                else if( convex(neweve[0]->co, neweve[3]->co, neweve[1]->co, neweve[2]->co) ) {
                                                        efa= addfacelist(em, neweve[0], neweve[3], neweve[1], neweve[2], NULL, NULL);
                                                }
-                                               else printf("cannot find nice quad from concave set of vertices\n");
+                                               else BKE_report(op->reports, RPT_ERROR, "cannot find nice quad from concave set of vertices");
+
                                        }
                                }
                        }
index 69043d9fa98d2e214238f0579db8f9504cb940ef..b3e967292018de17356d47d46f2882f632baa313 100644 (file)
@@ -432,7 +432,7 @@ void EM_select_face_fgon(EditMesh *em, EditFace *efa, int val)
                if(efa->e3->fgoni) index= efa->e3->fgoni;
                if(efa->v4 && efa->e4->fgoni) index= efa->e4->fgoni;
                
-               if(index==0) printf("wrong fgon select\n");
+               if((index==0) && (G.f & G_DEBUG))printf("wrong fgon select\n");
                
                // select all ngon faces with index
                for(efa= em->faces.first; efa; efa= efa->next) {
index ea444b2d0149c1ccb1db971f574ef181ebc208e6..2cd5f221ebed004e1896761ec74a6fa5c727e434 100644 (file)
@@ -682,7 +682,6 @@ static int knife_cut_exec(bContext *C, wmOperator *op)
                        if (isect!=0.0f) eed->f2= 1;
                        else eed->f2=0;
                        eed->tmp.fp= isect;
-                       //printf("isect=%i\n", isect);
                }
                else {
                        eed->f2=0;
index fbee03e3a303e801990e017df9f708e50146e4b3..3a7ab3a101de192dae1b9ef217b6c7354fe635cb 100644 (file)
@@ -1397,7 +1397,8 @@ void single_obdata_users(Scene *scene, int flag)
                                        armature_rebuild_pose(ob, ob->data);
                                        break;
                                default:
-                                       printf("ERROR single_obdata_users: can't copy %s\n", id->name);
+                                       if (G.f & G_DEBUG)
+                                               printf("ERROR single_obdata_users: can't copy %s\n", id->name);
                                        return;
                                }
                                
index 23411d2219fe6c0382e6dead72c2c13780f465be..20241f16c4fb2a37344f1e3aaca8f2c76f6d7288 100644 (file)
@@ -543,7 +543,8 @@ static void vgroup_duplicate(Object *ob)
                BLI_snprintf(name, 32, "%s_copy", dg->name);
                while(get_named_vertexgroup(ob, name)) {
                        if((strlen(name) + 6) > 32) {
-                               printf("Internal error: the name for the new vertex group is > 32 characters");
+                               if (G.f & G_DEBUG)
+                                       printf("Internal error: the name for the new vertex group is > 32 characters");
                                return;
                        }
                        strcpy(s, name);
index f94835593c58e07c86f9b4f597ad178f9f2c59f7..e567c940546e1d1ec3ba7e4b7db054e54176df2d 100644 (file)
@@ -44,6 +44,7 @@
 #include "BKE_depsgraph.h"
 #include "BKE_DerivedMesh.h"
 #include "BKE_cdderivedmesh.h"
+#include "BKE_global.h"
 #include "BKE_main.h"
 #include "BKE_particle.h"
 #include "BKE_pointcache.h"
@@ -654,7 +655,8 @@ static void connect_hair(Scene *scene, Object *ob, ParticleSystem *psys)
                BLI_bvhtree_find_nearest(bvhtree.tree, key->co, &nearest, bvhtree.nearest_callback, &bvhtree);
 
                if(nearest.index == -1) {
-                       printf("No nearest point found for hair root!");
+                       if (G.f & G_DEBUG)
+                               printf("No nearest point found for hair root!");
                        continue;
                }
 
index 7fb4dd5767204e1a62b09cdb58715762084506e6..a7a3754d16f1bc0bb537f8314bdb0e9bea9887fe 100644 (file)
@@ -728,7 +728,8 @@ static void region_rect_recursive(ScrArea *sa, ARegion *ar, rcti *remainder, int
                        if(count!=4) {
                                /* let's stop adding regions */
                                BLI_init_rcti(remainder, 0, 0, 0, 0);
-                               printf("region quadsplit failed\n");
+                               if (G.f & G_DEBUG)
+                                       printf("region quadsplit failed\n");
                        }
                        else quad= 1;
                }
index 20c629ab69c8f76f3a8a8b03b599c000214a3fe8..786f9ee9e3f7795616384a3e8b6f55abf1aebeb4 100644 (file)
@@ -1473,7 +1473,8 @@ ScrArea *ed_screen_fullarea(bContext *C, wmWindow *win, ScrArea *sa)
                        for(old= sc->areabase.first; old; old= old->next) 
                                if(old->full) break;
                        if(old==NULL) {
-                               printf("something wrong in areafullscreen\n"); 
+                               if (G.f & G_DEBUG)
+                                       printf("something wrong in areafullscreen\n"); 
                                return NULL;
                        }
                            // old feature described below (ton)
index 0b26b531d89899434c23e8a9f7623cda626c82d2..ef559615e2bc1f1ac4bd906d7a56b11511e66301 100644 (file)
@@ -2268,7 +2268,6 @@ static int header_flip_exec(bContext *C, wmOperator *op)
 #endif
 
        WM_event_add_notifier(C, NC_SCREEN|NA_EDITED, NULL);
-       printf("executed header region flip\n");
        
        return OPERATOR_FINISHED;
 }
@@ -2946,7 +2945,8 @@ static void make_renderinfo_string(RenderStats *rs, Scene *scene, char *str)
        
        /* very weak... but 512 characters is quite safe */
        if(spos >= str+IMA_RW_MAXTEXT)
-               printf("WARNING! renderwin text beyond limit \n");
+               if (G.f & G_DEBUG)
+                       printf("WARNING! renderwin text beyond limit \n");
        
 }
 
@@ -3484,15 +3484,23 @@ static int screen_opengl_render_anim_step(bContext *C, wmOperator *op)
        if(ibuf) {
                if(BKE_imtype_is_movie(scene->r.imtype)) {
                        ok= oglrender->mh->append_movie(&scene->r, CFRA, (int*)ibuf->rect, oglrender->sizex, oglrender->sizey, oglrender->reports);
-                       if(ok)
+                       if(ok) {
                                printf("Append frame %d", scene->r.cfra);
+                               BKE_reportf(op->reports, RPT_INFO, "Appended frame: %d", scene->r.cfra);
+                       }
                }
                else {
                        BKE_makepicstring(name, scene->r.pic, scene->r.cfra, scene->r.imtype, scene->r.scemode & R_EXTENSION);
                        ok= BKE_write_ibuf(scene, ibuf, name, scene->r.imtype, scene->r.subimtype, scene->r.quality);
                        
-                       if(ok==0) printf("write error: cannot save %s\n", name);
-                       else printf("saved: %s", name);
+                       if(ok==0) {
+                               printf("Write error: cannot save %s\n", name);
+                               BKE_reportf(op->reports, RPT_ERROR, "Write error: cannot save %s", name);
+                       }
+                       else {
+                               printf("Saved: %s", name);
+                               BKE_reportf(op->reports, RPT_INFO, "Saved file: %s", name);
+                       }
                }
        }
        
index a756eff8c119e1890541fb8c22fba930e47ca325..6f2052958ce443af7d2530c48f94b6fab3776ef4 100644 (file)
@@ -249,9 +249,10 @@ static void screenshot_startjob(void *sjv, short *stop, short *do_update)
                if(sj->dumprect) {
                        
                        if(mh) {
-                               if(mh->append_movie(&rd, cfra, (int *)sj->dumprect, sj->dumpsx, sj->dumpsy, &sj->reports))
-                                       printf("Append frame %d\n", cfra);
-                               else
+                               if(mh->append_movie(&rd, cfra, (int *)sj->dumprect, sj->dumpsx, sj->dumpsy, &sj->reports)) {
+                                       BKE_reportf(&sj->reports, RPT_INFO, "Appended frame: %d", cfra);
+                                       printf("Appended frame %d\n", cfra);
+                               } else
                                        break;
                        }
                        else {
@@ -266,9 +267,13 @@ static void screenshot_startjob(void *sjv, short *stop, short *do_update)
                                
                                if(ok==0) {
                                        printf("Write error: cannot save %s\n", name);
+                                       BKE_reportf(&sj->reports, RPT_INFO, "Write error: cannot save %s\n", name);
                                        break;
                                }
-                               else printf("Saved: %s\n", name);
+                               else {
+                                       printf("Saved file: %s\n", name);
+                                       BKE_reportf(&sj->reports, RPT_INFO, "Saved file: %s", name);
+                               }
                                
                 /* imbuf knows which rects are not part of ibuf */
                                IMB_freeImBuf(ibuf);    
@@ -288,7 +293,8 @@ static void screenshot_startjob(void *sjv, short *stop, short *do_update)
        
        if(mh)
                mh->end_movie();
-       printf("screencast job stopped\n");
+
+       BKE_report(&sj->reports, RPT_INFO, "Screencast job stopped");
 }
 
 static int screencast_exec(bContext *C, wmOperator *op)
index 6b901814634de111c572381c0ba09a39bdddfa9b..b730f075f8f5dc9581687f0eb43a6c23944822d0 100644 (file)
@@ -1079,7 +1079,7 @@ static int save_sequence_exec(bContext *C, wmOperator *op)
                                break;
                        }
 
-                       printf("Saved: %s\n", ibuf->name);
+                       BKE_reportf(op->reports, RPT_INFO, "Saved: %s\n", ibuf->name);
                        ibuf->userflags &= ~IB_BITMAPDIRTY;
                }
        }
index aba262bf92b69402555e68b13cd3dfbcff74803c..f77eeec9cc83d44467d50c8a80cc3e13716975be 100644 (file)
@@ -242,7 +242,8 @@ void ED_node_shader_default(Material *ma)
        
        /* but lets check it anyway */
        if(ma->nodetree) {
-               printf("error in shader initialize\n");
+               if (G.f & G_DEBUG)
+                       printf("error in shader initialize\n");
                return;
        }
        
@@ -272,7 +273,8 @@ void ED_node_composit_default(Scene *sce)
        
        /* but lets check it anyway */
        if(sce->nodetree) {
-               printf("error in composit initialize\n");
+               if (G.f & G_DEBUG)
+                       printf("error in composite initialize\n");
                return;
        }
        
@@ -306,7 +308,8 @@ void ED_node_texture_default(Tex *tx)
        
        /* but lets check it anyway */
        if(tx->nodetree) {
-               printf("error in texture initialize\n");
+               if (G.f & G_DEBUG)
+                       printf("error in texture initialize\n");
                return;
        }
        
index 5ca10de8456577be984e909cec997a93f17ebbac..079db41f8c8e1d6ec68d90d547a948497cc16fcb 100644 (file)
@@ -203,7 +203,7 @@ static void v3d_editvertex_buts(const bContext *C, uiLayout *layout, View3D *v3d
                                        max+= BLI_snprintf(str, sizeof(str), "%s %%x%d|", dg->name, dvert->dw[i].def_nr); 
                                        if(max<320) strcat(defstr, str);
                                }
-                               else printf("oh no!\n");
+
                                if(tfp->curdef==dvert->dw[i].def_nr) {
                                        init= 0;
                                        tfp->defweightp= &dvert->dw[i].weight;
@@ -1135,11 +1135,13 @@ static void redo_cb(bContext *C, void *arg_op, void *arg2)
        if(lastop) {
                int retval;
                
-               printf("operator redo %s\n", lastop->type->name);
+               if (G.f & G_DEBUG)
+                       printf("operator redo %s\n", lastop->type->name);
                ED_undo_pop(C);
                retval= WM_operator_repeat(C, lastop);
                if((retval & OPERATOR_FINISHED)==0) {
-                       printf("operator redo failed %s\n", lastop->type->name);
+                       if (G.f & G_DEBUG)
+                               printf("operator redo failed %s\n", lastop->type->name);
                        ED_undo_redo(C);
                }
        }
index eb292b4bcccb22fe884850c9498ac05fe2bc107a..8d354c1b565d4079b112ebbe4e6ca4e055f0b0e4 100644 (file)
@@ -108,11 +108,13 @@ static void redo_cb(bContext *C, void *arg_op, void *arg2)
        if(lastop) {
                int retval;
                
-               printf("operator redo %s\n", lastop->type->name);
+               if (G.f & G_DEBUG)
+                       printf("operator redo %s\n", lastop->type->name);
                ED_undo_pop_op(C, lastop);
                retval= WM_operator_repeat(C, lastop);
                if((retval & OPERATOR_FINISHED)==0) {
-                       printf("operator redo failed %s\n", lastop->type->name);
+                       if (G.f & G_DEBUG)
+                               printf("operator redo failed %s\n", lastop->type->name);
                        ED_undo_redo(C);
                }
        }