From 820b6b37310fe5245f8858392a3284614451cea5 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Wed, 7 Jan 2015 12:31:25 +0100 Subject: Ensure mat/tex/etc. previews are generated/saved in .blend files when enabled in userprefs. Reviewers: campbellbarton Differential Revision: https://developer.blender.org/D970 --- source/blender/windowmanager/intern/wm_files.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'source/blender/windowmanager/intern/wm_files.c') diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c index c1c31f6795d..622e86a8e02 100644 --- a/source/blender/windowmanager/intern/wm_files.c +++ b/source/blender/windowmanager/intern/wm_files.c @@ -101,6 +101,7 @@ #include "GHOST_Path-api.h" #include "UI_interface.h" +#include "UI_interface_icons.h" #include "UI_view2d.h" #include "GPU_draw.h" @@ -894,6 +895,23 @@ bool write_crash_blend(void) } } +static void wm_ensure_previews(bContext *C, Main *mainvar) +{ + ListBase *lb[] = {&mainvar->mat, &mainvar->tex, &mainvar->image, &mainvar->world, &mainvar->lamp, NULL}; + ID *id; + int i; + + for (i = 0; lb[i]; i++) { + for (id = lb[i]->first; id; id = id->next) { + /* Only preview non-library datablocks, lib ones do not pertain to this .blend file! */ + if (!id->lib) { + UI_id_icon_render(C, id, false, false); + UI_id_icon_render(C, id, true, false); + } + } + } +} + /** * \see #wm_homefile_write_exec wraps #BLO_write_file in a similar way. */ @@ -938,6 +956,8 @@ int wm_file_write(bContext *C, const char *filepath, int fileflags, ReportList * /* save before exit_editmode, otherwise derivedmeshes for shared data corrupt #27765) */ if ((U.flag & USER_SAVE_PREVIEWS) && BLI_thread_is_main()) { ibuf_thumb = blend_file_thumb(CTX_data_scene(C), CTX_wm_screen(C), &thumb); + + wm_ensure_previews(C, G.main); } BLI_callback_exec(G.main, NULL, BLI_CB_EVT_SAVE_PRE); -- cgit v1.2.3