[Bf-blender-cvs] [3c738b3] asset-experiments: Never write preview data when doing memsave (i.e. undo).

Bastien Montagne noreply at git.blender.org
Tue Dec 16 18:05:18 CET 2014


Commit: 3c738b301f82a5e7fd4666474c3e727fd248923c
Author: Bastien Montagne
Date:   Tue Dec 16 11:50:15 2014 +0100
Branches: asset-experiments
https://developer.blender.org/rB3c738b301f82a5e7fd4666474c3e727fd248923c

Never write preview data when doing memsave (i.e. undo).

Takes useless space, and they even could easily get out of sync.

Also, some minor preparative work to (re)generate previews on file write,
if needed!

===================================================================

M	source/blender/blenloader/intern/writefile.c
M	source/blender/editors/include/UI_interface_icons.h
M	source/blender/editors/interface/interface_icons.c

===================================================================

diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c
index 7a0d843..e464573 100644
--- a/source/blender/blenloader/intern/writefile.c
+++ b/source/blender/blenloader/intern/writefile.c
@@ -590,7 +590,8 @@ void IDP_WriteProperty(IDProperty *prop, void *wd)
 
 static void write_previews(WriteData *wd, PreviewImage *prv)
 {
-	if (prv) {
+	/* Never write previews when doing memsave (i.e. undo/redo)! */
+	if (prv && !wd->current) {
 		short w = prv->w[1];
 		short h = prv->h[1];
 		unsigned int *rect = prv->rect[1];
diff --git a/source/blender/editors/include/UI_interface_icons.h b/source/blender/editors/include/UI_interface_icons.h
index 3938fa7..16221db 100644
--- a/source/blender/editors/include/UI_interface_icons.h
+++ b/source/blender/editors/include/UI_interface_icons.h
@@ -33,6 +33,7 @@
 #define __UI_INTERFACE_ICONS_H__
 
 struct bContext;
+struct ID;
 struct Image;
 struct ImBuf;
 struct World;
@@ -50,12 +51,11 @@ typedef struct IconFile {
 
 #define ICON_DEFAULT_HEIGHT 16
 #define ICON_DEFAULT_WIDTH  16
+#define PREVIEW_DEFAULT_HEIGHT 128
 
 #define ICON_DEFAULT_HEIGHT_SCALE ((int)(UI_UNIT_Y * 0.8f))
 #define ICON_DEFAULT_WIDTH_SCALE  ((int)(UI_UNIT_X * 0.8f))
 
-#define PREVIEW_DEFAULT_HEIGHT 128
-
 #define ICON_RENDER_DEFAULT_HEIGHT 32
 #define PREVIEW_RENDER_DEFAULT_HEIGHT 128
 
@@ -66,6 +66,8 @@ void UI_icons_init(int first_dyn_id);
 int UI_icon_get_width(int icon_id);
 int UI_icon_get_height(int icon_id);
 
+void UI_id_icon_render(struct bContext *C, struct ID *id, const bool big);
+
 void UI_icon_draw(float x, float y, int icon_id);
 void UI_icon_draw_preview(float x, float y, int icon_id);
 void UI_icon_draw_preview_aspect(float x, float y, int icon_id, float aspect);
diff --git a/source/blender/editors/interface/interface_icons.c b/source/blender/editors/interface/interface_icons.c
index addeeb5..f2d50a1 100644
--- a/source/blender/editors/interface/interface_icons.c
+++ b/source/blender/editors/interface/interface_icons.c
@@ -1217,13 +1217,16 @@ static void ui_id_preview_image_render_size(bContext *C, ID *id, PreviewImage *p
 {
 	if ((pi->changed[size] || !pi->rect[size])) { /* changed only ever set by dynamic icons */
 		/* create the rect if necessary */
+
+		printf("%s: %s\n", __func__, id->name);
+
 		icon_set_image(C, id, pi, size);
 
 		pi->changed[size] = 0;
 	}
 }
 
-static void ui_id_icon_render(bContext *C, ID *id, const bool big)
+void UI_id_icon_render(bContext *C, ID *id, const bool big)
 {
 	PreviewImage *pi = BKE_previewimg_get(id);
 
@@ -1247,6 +1250,9 @@ static void ui_id_brush_render(bContext *C, ID *id)
 		/* check if rect needs to be created; changed
 		 * only set by dynamic icons */
 		if ((pi->changed[i] || !pi->rect[i])) {
+
+			printf("%s: %s\n", __func__, id->name);
+
 			icon_set_image(C, id, pi, i);
 			pi->changed[i] = 0;
 		}
@@ -1323,7 +1329,7 @@ int ui_id_icon_get(bContext *C, ID *id, const bool big)
 		case ID_LA: /* fall through */
 			iconid = BKE_icon_getid(id);
 			/* checks if not exists, or changed */
-			ui_id_icon_render(C, id, big);
+			UI_id_icon_render(C, id, big);
 			break;
 		default:
 			break;




More information about the Bf-blender-cvs mailing list