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:
Diffstat (limited to 'source/blender/windowmanager/intern/wm_files.c')
-rw-r--r--source/blender/windowmanager/intern/wm_files.c31
1 files changed, 24 insertions, 7 deletions
diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c
index 5d005e23029..27fc0caeccc 100644
--- a/source/blender/windowmanager/intern/wm_files.c
+++ b/source/blender/windowmanager/intern/wm_files.c
@@ -57,6 +57,7 @@
#include "BLI_blenlib.h"
#include "BLI_linklist.h"
#include "BLI_utildefines.h"
+#include "BLI_callbacks.h"
#include "DNA_anim_types.h"
#include "DNA_ipo_types.h" // XXX old animation system
@@ -342,6 +343,8 @@ void WM_read_file(bContext *C, const char *filepath, ReportList *reports)
WM_cursor_wait(1);
+ BLI_exec_cb(CTX_data_main(C), NULL, BLI_CB_EVT_LOAD_PRE);
+
/* first try to append data from exotic file formats... */
/* it throws error box when file doesnt exist and returns -1 */
/* note; it should set some error message somewhere... (ton) */
@@ -392,6 +395,7 @@ void WM_read_file(bContext *C, const char *filepath, ReportList *reports)
#ifdef WITH_PYTHON
/* run any texts that were loaded in and flagged as modules */
BPY_driver_reset();
+ BPY_app_handlers_reset();
BPY_modules_load_user(C);
#endif
CTX_wm_window_set(C, NULL); /* exits queues */
@@ -411,7 +415,8 @@ void WM_read_file(bContext *C, const char *filepath, ReportList *reports)
// XXX undo_editmode_clear();
BKE_reset_undo();
BKE_write_undo(C, "original"); /* save current state */
-
+
+ BLI_exec_cb(CTX_data_main(C), NULL, BLI_CB_EVT_LOAD_POST);
}
else if(retval == BKE_READ_EXOTIC_OK_OTHER)
BKE_write_undo(C, "Import file");
@@ -518,6 +523,7 @@ int WM_read_homefile(bContext *C, ReportList *reports, short from_memory)
BPY_string_exec(C, "__import__('addon_utils').reset_all()");
BPY_driver_reset();
+ BPY_app_handlers_reset();
BPY_modules_load_user(C);
}
#endif
@@ -629,8 +635,9 @@ static ImBuf *blend_file_thumb(Scene *scene, int **thumb_pt)
char err_out[256]= "unknown";
*thumb_pt= NULL;
-
- if(G.background || scene->camera==NULL)
+
+ /* scene can be NULL if running a script at startup and calling the save operator */
+ if(G.background || scene==NULL || scene->camera==NULL)
return NULL;
/* gets scaled to BLEN_THUMB_SIZE */
@@ -716,6 +723,14 @@ int WM_write_file(bContext *C, const char *target, int fileflags, ReportList *re
}
}
+ /* blend file thumbnail */
+ /* save before exit_editmode, otherwise derivedmeshes for shared data corrupt #27765) */
+ if(U.flag & USER_SAVE_PREVIEWS) {
+ ibuf_thumb= blend_file_thumb(CTX_data_scene(C), &thumb);
+ }
+
+ BLI_exec_cb(G.main, NULL, BLI_CB_EVT_SAVE_PRE);
+
/* operator now handles overwrite checks */
if (G.fileflags & G_AUTOPACK) {
@@ -728,9 +743,6 @@ int WM_write_file(bContext *C, const char *target, int fileflags, ReportList *re
/* don't forget not to return without! */
WM_cursor_wait(1);
- /* blend file thumbnail */
- ibuf_thumb= blend_file_thumb(CTX_data_scene(C), &thumb);
-
fileflags |= G_FILE_HISTORY; /* write file history */
if (BLO_write_file(CTX_data_main(C), filepath, fileflags, reports, thumb)) {
@@ -747,7 +759,12 @@ int WM_write_file(bContext *C, const char *target, int fileflags, ReportList *re
if(fileflags & G_FILE_AUTOPLAY) G.fileflags |= G_FILE_AUTOPLAY;
else G.fileflags &= ~G_FILE_AUTOPLAY;
- write_history();
+ /* prevent background mode scripts from clobbering history */
+ if(!G.background) {
+ write_history();
+ }
+
+ BLI_exec_cb(G.main, NULL, BLI_CB_EVT_SAVE_POST);
/* run this function after because the file cant be written before the blend is */
if (ibuf_thumb) {