fix for uninitialized value in BLI_path_cwd() if PWD wasn't defined and the CWD was...
[blender.git] / source / blender / editors / interface / interface_icons.c
index bd79353..32b2787 100644 (file)
@@ -614,7 +614,7 @@ static void init_iconfile_list(struct ListBase *list)
        
        /* since BLI_getdir changes the current working directory, restore it 
           back to old value afterwards */
-       if(!BLI_getwdN(olddir)) 
+       if(!BLI_getwdN(olddir, sizeof(olddir))) 
                restoredir = 0;
        totfile = BLI_getdir(icondirstr, &dir);
        if (restoredir && !chdir(olddir)) {} /* fix warning about checking return value */
@@ -1001,17 +1001,35 @@ static void icon_draw_size(float x, float y, int icon_id, float aspect, float al
        }
 }
 
-void ui_id_icon_render(bContext *C, ID *id, int UNUSED(preview))
+static void ui_id_icon_render(bContext *C, ID *id, int big)
+{
+       PreviewImage *pi = BKE_previewimg_get(id); 
+       
+       if (pi) {                       
+               if ((pi->changed[0] ||!pi->rect[0])) /* changed only ever set by dynamic icons */
+               {
+                       /* create the rect if necessary */                              
+                       
+                       icon_set_image(C, id, pi, 0);           /* icon size */
+                       if (big)
+                               icon_set_image(C, id, pi, 1);   /* bigger preview size */
+                       
+                       pi->changed[0] = 0;
+               }
+       }
+}
+
+static void ui_id_brush_render(bContext *C, ID *id)
 {
        PreviewImage *pi = BKE_previewimg_get(id); 
        int i;
-               
+       
        if(!pi)
                return;
-
+       
        for(i = 0; i < PREVIEW_MIPMAPS; i++) {
-               /* check if preview rect needs to be created; changed
-                  only set by dynamic icons */
+               /* check if rect needs to be created; changed
+                only set by dynamic icons */
                if((pi->changed[i] || !pi->rect[i])) {
                        icon_set_image(C, id, pi, i);
                        pi->changed[i] = 0;
@@ -1019,13 +1037,14 @@ void ui_id_icon_render(bContext *C, ID *id, int UNUSED(preview))
        }
 }
 
-static int ui_id_brush_get_icon(bContext *C, ID *id, int preview)
+
+static int ui_id_brush_get_icon(bContext *C, ID *id)
 {
        Brush *br = (Brush*)id;
 
        if(br->flag & BRUSH_CUSTOM_ICON) {
                BKE_icon_getid(id);
-               ui_id_icon_render(C, id, preview);
+               ui_id_brush_render(C, id);
        }
        else {
                Object *ob = CTX_data_active_object(C);
@@ -1071,7 +1090,7 @@ static int ui_id_brush_get_icon(bContext *C, ID *id, int preview)
        return id->icon_id;
 }
 
-int ui_id_icon_get(bContext *C, ID *id, int preview)
+int ui_id_icon_get(bContext *C, ID *id, int big)
 {
        int iconid= 0;
        
@@ -1079,7 +1098,7 @@ int ui_id_icon_get(bContext *C, ID *id, int preview)
        switch(GS(id->name))
        {
                case ID_BR:
-                       iconid= ui_id_brush_get_icon(C, id, preview);
+                       iconid= ui_id_brush_get_icon(C, id);
                        break;
                case ID_MA: /* fall through */
                case ID_TE: /* fall through */
@@ -1088,7 +1107,7 @@ int ui_id_icon_get(bContext *C, ID *id, int preview)
                case ID_LA: /* fall through */
                        iconid= BKE_icon_getid(id);
                        /* checks if not exists, or changed */
-                       ui_id_icon_render(C, id, preview);
+                       ui_id_icon_render(C, id, big);
                        break;
                default:
                        break;