Fix for bug #26590, `Texture preview fails when path to custom brush
authorNicholas Bishop <nicholasbishop@gmail.com>
Wed, 27 Apr 2011 01:16:24 +0000 (01:16 +0000)
committerNicholas Bishop <nicholasbishop@gmail.com>
Wed, 27 Apr 2011 01:16:24 +0000 (01:16 +0000)
icon is set'

* Main problem was calling BKE_icon_changed too much, blocked previews
  from updating
* Also fixed clearing the icon when it's not a valid image path

link: http://codereview.appspot.com/4356045/
source/blender/editors/render/render_preview.c

index 239b078a9108f55ceb34898a01c4545b16b2bc57..905f88c5f901575960c8226db7b1ba08a6b763b1 100644 (file)
@@ -135,14 +135,15 @@ ImBuf* get_brush_icon(Brush *brush)
                                        if (path[0])
                                                brush->icon_imbuf= IMB_loadiffname(path, flags);
                                }
+
+                               if (brush->icon_imbuf)
+                                       BKE_icon_changed(BKE_icon_getid(&brush->id));
                        }
                }
        }
 
        if (!(brush->icon_imbuf))
                brush->id.icon_id = 0;
-       else
-               BKE_icon_changed(BKE_icon_getid(&(brush->id)));
 
        return brush->icon_imbuf;
 }
@@ -1256,10 +1257,11 @@ static void icon_preview_startjob(void *customdata, short *stop, short *do_updat
 
                br->icon_imbuf= get_brush_icon(br);
 
+               memset(sp->pr_rect, 0x888888, sp->sizex*sp->sizey*sizeof(unsigned int));
+
                if(!(br->icon_imbuf) || !(br->icon_imbuf->rect))
                        return;
 
-               memset(sp->pr_rect, 0x888888, sp->sizex*sp->sizey*sizeof(unsigned int));
                icon_copy_rect(br->icon_imbuf, sp->sizex, sp->sizey, sp->pr_rect);
 
                *do_update= 1;