Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien Montagne <montagne29@wanadoo.fr>2015-01-07 14:31:25 +0300
committerBastien Montagne <montagne29@wanadoo.fr>2015-01-07 14:31:31 +0300
commit820b6b37310fe5245f8858392a3284614451cea5 (patch)
tree8e835f02b7a398c0b633fc6d936152d58ace02c9 /source/blender/windowmanager/intern/wm_files.c
parent3f05797333dd86279f33e1868b3dd737a1f3a825 (diff)
Ensure mat/tex/etc. previews are generated/saved in .blend files when enabled in userprefs.
Reviewers: campbellbarton Differential Revision: https://developer.blender.org/D970
Diffstat (limited to 'source/blender/windowmanager/intern/wm_files.c')
-rw-r--r--source/blender/windowmanager/intern/wm_files.c20
1 files changed, 20 insertions, 0 deletions
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);