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:
authorSybren A. Stüvel <sybren@stuvel.eu>2018-10-12 11:24:07 +0300
committerSybren A. Stüvel <sybren@stuvel.eu>2018-10-12 11:24:25 +0300
commitcd3b313d5f44a10a1150bf1ddb560775d1bcd827 (patch)
treee1c86c69ea0652da8c99eee9ab278a08a3c06c86 /source/blender/windowmanager/intern/wm_files.c
parent5eeb6c00be8de7db5608d6831a0d88bd39611771 (diff)
Prevent G.fileflags changes when WM_OT_save_mainfile() is called from script
This is to solve an issue where a blend file could be compressed unbeknownst to the artist. This happened in the following situtation: - Artist edits an uncompressed blend file. - Some script saves a compressed blendfile to a separate location. - When the artist saves the file (s)he is editing (File>Save, or Ctrl+S), it was silently compressed.
Diffstat (limited to 'source/blender/windowmanager/intern/wm_files.c')
-rw-r--r--source/blender/windowmanager/intern/wm_files.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c
index a52b97254be..1195348ed0d 100644
--- a/source/blender/windowmanager/intern/wm_files.c
+++ b/source/blender/windowmanager/intern/wm_files.c
@@ -2166,7 +2166,7 @@ static int wm_save_as_mainfile_exec(bContext *C, wmOperator *op)
{
Main *bmain = CTX_data_main(C);
char path[FILE_MAX];
- int fileflags;
+ int fileflags, orig_fileflags;
save_set_compress(op);
@@ -2178,6 +2178,7 @@ static int wm_save_as_mainfile_exec(bContext *C, wmOperator *op)
wm_filepath_default(path);
}
+ orig_fileflags = G.fileflags;
fileflags = G.fileflags & ~G_FILE_USERPREFS;
/* set compression flag */
@@ -2193,8 +2194,18 @@ static int wm_save_as_mainfile_exec(bContext *C, wmOperator *op)
RNA_boolean_get(op->ptr, "copy")),
G_FILE_SAVE_COPY);
- if (wm_file_write(C, path, fileflags, op->reports) != 0)
+ int write_result = wm_file_write(C, path, fileflags, op->reports);
+
+ if ((op->flag & OP_IS_INVOKE) == 0) {
+ /* OP_IS_INVOKE is set when the operator is called from the GUI.
+ * If it is not set, the operator is called from a script and
+ * shouldn't influence G.fileflags. */
+ G.fileflags = orig_fileflags;
+ }
+
+ if (write_result != 0) {
return OPERATOR_CANCELLED;
+ }
WM_event_add_notifier(C, NC_WM | ND_FILESAVE, NULL);