fix for various redundant checks and possibly fix some crashes in rare situations.
authorCampbell Barton <ideasman42@gmail.com>
Wed, 5 Sep 2012 01:42:52 +0000 (01:42 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Wed, 5 Sep 2012 01:42:52 +0000 (01:42 +0000)
source/blender/blenloader/intern/readfile.c
source/blender/editors/interface/interface_ops.c
source/blender/editors/space_view3d/drawmesh.c
source/blender/imbuf/intern/moviecache.c
source/blender/nodes/composite/node_composite_tree.c
source/blender/render/intern/source/render_texture.c

index 5bcd8c356255c7b9b741dcdf4b95aa39470d2cab..04c9d96ea0f61d8830190c7e74e592e34f827ba0 100644 (file)
@@ -9471,9 +9471,9 @@ static void read_libraries(FileData *basefd, ListBase *mainlist)
                                                                cleanup_path(G.main->name, mainptr->curlib->filepath);
                                                                
                                                                fd = blo_openblenderfile(mainptr->curlib->filepath, basefd->reports);
-                                                               fd->mainlist = mainlist;
-                                                               
+
                                                                if (fd) {
+                                                                       fd->mainlist = mainlist;
                                                                        printf("found: '%s', party on macuno!\n", mainptr->curlib->filepath);
                                                                }
                                                        }
index 67c0d04a79f6e18a554c1fb7abafff986386aa5c..e8b8959fd43c3df537ca4a4f25aba4fd75c63cca 100644 (file)
@@ -908,19 +908,19 @@ static void UI_OT_editsource(wmOperatorType *ot)
 
 void edittranslation_find_po_file(const char *root, const char *uilng, char *path, const size_t maxlen)
 {
-       char t[32]; /* Should be more than enough! */
+       char tstr[32]; /* Should be more than enough! */
        /* First, full lang code. */
-       sprintf(t, "%s.po", uilng);
+       BLI_snprintf(tstr, sizeof(tstr), "%s.po", uilng);
        BLI_join_dirfile(path, maxlen, root, uilng);
-       BLI_join_dirfile(path, maxlen, path, t);
+       BLI_join_dirfile(path, maxlen, path, tstr);
        if (BLI_is_file(path))
                return;
        /* Now try without the second iso code part (_ES in es_ES). */
-       strncpy(t, uilng, 2);
-       strcpy(t + 2, uilng + 5); /* Because of some codes like sr_SR@latin... */
-       BLI_join_dirfile(path, maxlen, root, t);
-       sprintf(t, "%s.po", t);
-       BLI_join_dirfile(path, maxlen, path, t);
+       strncpy(tstr, uilng, 2);
+       BLI_strncpy(tstr + 2, uilng + 5, sizeof(tstr) - 2); /* Because of some codes like sr_SR@latin... */
+       BLI_join_dirfile(path, maxlen, root, tstr);
+       strcat(tstr, ".po");
+       BLI_join_dirfile(path, maxlen, path, tstr);
        if (BLI_is_file(path))
                return;
        path[0] = '\0';
index d2b3bcf682548871c1cee7e767a5f0824955afcd..da93e07748a08ad066da626710cfd18ff8f9ce39 100644 (file)
@@ -1030,7 +1030,7 @@ void draw_mesh_paint(View3D *v3d, RegionView3D *rv3d,
        if (draw_flags & DRAW_FACE_SELECT)
                facemask = wpaint__setSolidDrawOptions_facemask;
 
-       if (ob && ob->mode & OB_MODE_WEIGHT_PAINT) {
+       if (ob->mode & OB_MODE_WEIGHT_PAINT) {
 
                if (do_light) {
                        const float spec[4] = {0.47f, 0.47f, 0.47f, 0.47f};
index 71eae6c6c21097d378cb705fec6a6f2bcec9d36b..f91f648bb7bc8d4bce615f152438e3af8f7b301b 100644 (file)
@@ -172,12 +172,13 @@ static int compare_int(const void *av, const void *bv)
 
 static void IMB_moviecache_destructor(void *p)
 {
-       MovieCacheItem *item = (MovieCacheItem *) p;
-       MovieCache *cache = item->cache_owner;
-
-       PRINT("%s: cache '%s' destroy item %p buffer %p\n", __func__, cache->name, item, item->ibuf);
+       MovieCacheItem *item = (MovieCacheItem *)p;
 
        if (item && item->ibuf) {
+               MovieCache *cache = item->cache_owner;
+
+               PRINT("%s: cache '%s' destroy item %p buffer %p\n", __func__, cache->name, item, item->ibuf);
+
                IMB_freeImBuf(item->ibuf);
 
                item->ibuf = NULL;
index 55750ca1bab395e10a26e0128a799480ff5230c0..07db1ce1a1871e2459d31c356ea10563c98946c2 100644 (file)
@@ -606,11 +606,9 @@ static void ntreeCompositExecTreeOld(bNodeTree *ntree, RenderData *rd, int do_pr
        bNode *node;
        ListBase threads;
        ThreadData thdata;
-       int totnode, curnode, rendering= 1, n;
-       bNodeTreeExec *exec= ntree->execdata;
-       
-       if (ntree == NULL) return;
-       
+       int totnode, curnode, rendering = TRUE, n;
+       bNodeTreeExec *exec = ntree->execdata;
+
        if (do_preview)
                ntreeInitPreview(ntree, 0, 0);
        
index 14c178c10f9e6ed9bedb9767c25b7ddb720c53c3..cbe8cc814513b812c5e14ae3646275599e1a614a 100644 (file)
@@ -93,13 +93,9 @@ extern struct Render R;
 
 static void init_render_texture(Render *re, Tex *tex)
 {
-       int cfra= re->scene->r.cfra;
-       
-       if (re) cfra= re->r.cfra;
-       
        /* imap test */
        if (tex->ima && ELEM(tex->ima->source, IMA_SRC_MOVIE, IMA_SRC_SEQUENCE)) {
-               BKE_image_user_frame_calc(&tex->iuser, cfra, re?re->flag & R_SEC_FIELD:0);
+               BKE_image_user_frame_calc(&tex->iuser, re->r.cfra, re?re->flag & R_SEC_FIELD:0);
        }
        
        else if (tex->type==TEX_ENVMAP) {