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:
authorCampbell Barton <ideasman42@gmail.com>2021-03-15 06:43:02 +0300
committerCampbell Barton <ideasman42@gmail.com>2021-03-15 06:53:29 +0300
commit684971c2f27d59e7a0938d59e047dc4b71ce0c25 (patch)
tree098ad74ae121a2f07a7d2dea3ed876ae963e4cc9
parent244315afc9bd905c6d725b5be2428fa6e382cd00 (diff)
WM: fallback to regular writing if auto-save can't access undo data
While this is very unlikely, always write the autosave file, even if the `memfile` undo data is unexpectedly NULL. Also use CLG for logging warnings.
-rw-r--r--source/blender/windowmanager/intern/wm_files.c22
1 files changed, 15 insertions, 7 deletions
diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c
index ca59174f8e8..a9b30f91bee 100644
--- a/source/blender/windowmanager/intern/wm_files.c
+++ b/source/blender/windowmanager/intern/wm_files.c
@@ -139,6 +139,8 @@
#include "wm_files.h"
#include "wm_window.h"
+#include "CLG_log.h"
+
static RecentFile *wm_file_history_find(const char *filepath);
static void wm_history_file_free(RecentFile *recent);
static void wm_history_files_free(void);
@@ -147,6 +149,8 @@ static void wm_history_file_write(void);
static void wm_test_autorun_revert_action_exec(bContext *C);
+static CLG_LogRef LOG = {"wm.files"};
+
/* -------------------------------------------------------------------- */
/** \name Misc Utility Functions
* \{ */
@@ -1440,7 +1444,7 @@ static ImBuf *blend_file_thumb(const bContext *C,
}
else {
/* '*thumb_pt' needs to stay NULL to prevent a bad thumbnail from being handled */
- fprintf(stderr, "blend_file_thumb failed to create thumbnail: %s\n", err_out);
+ CLOG_WARN(&LOG, "failed to create thumbnail: %s", err_out);
thumb = NULL;
}
@@ -1649,14 +1653,18 @@ static void wm_autosave_write(Main *bmain, wmWindowManager *wm)
wm_autosave_location(filepath);
- if (U.uiflag & USER_GLOBALUNDO) {
- /* fast save of last undobuffer, now with UI */
- struct MemFile *memfile = ED_undosys_stack_memfile_get_active(wm->undo_stack);
- if (memfile) {
- BLO_memfile_write_file(memfile, filepath);
- }
+ /* Fast save of last undo-buffer, now with UI. */
+ const bool use_memfile = (U.uiflag & USER_GLOBALUNDO) != 0;
+ MemFile *memfile = use_memfile ? ED_undosys_stack_memfile_get_active(wm->undo_stack) : NULL;
+ if (memfile != NULL) {
+ BLO_memfile_write_file(memfile, filepath);
}
else {
+ if (use_memfile) {
+ /* This is very unlikely, alert developers of this unexpected case. */
+ CLOG_WARN(&LOG, "undo-data not found for writing, fallback to regular file write!");
+ }
+
/* Save as regular blend file with recovery information. */
const int fileflags = (G.fileflags & ~G_FILE_COMPRESS) | G_FILE_RECOVER_WRITE;