Merge branch 'master' into blender2.8
This commit is contained in:
@@ -1187,12 +1187,12 @@ bool write_crash_blend(void)
|
||||
/**
|
||||
* \see #wm_homefile_write_exec wraps #BLO_write_file in a similar way.
|
||||
*/
|
||||
static int wm_file_write(bContext *C, const char *filepath, int fileflags, ReportList *reports)
|
||||
static bool wm_file_write(bContext *C, const char *filepath, int fileflags, ReportList *reports)
|
||||
{
|
||||
Main *bmain = CTX_data_main(C);
|
||||
Library *li;
|
||||
int len;
|
||||
int ret = -1;
|
||||
int ok = false;
|
||||
BlendThumbnail *thumb, *main_thumb;
|
||||
ImBuf *ibuf_thumb = NULL;
|
||||
|
||||
@@ -1200,18 +1200,18 @@ static int wm_file_write(bContext *C, const char *filepath, int fileflags, Repor
|
||||
|
||||
if (len == 0) {
|
||||
BKE_report(reports, RPT_ERROR, "Path is empty, cannot save");
|
||||
return ret;
|
||||
return ok;
|
||||
}
|
||||
|
||||
if (len >= FILE_MAX) {
|
||||
BKE_report(reports, RPT_ERROR, "Path too long, cannot save");
|
||||
return ret;
|
||||
return ok;
|
||||
}
|
||||
|
||||
/* Check if file write permission is ok */
|
||||
if (BLI_exists(filepath) && !BLI_file_is_writable(filepath)) {
|
||||
BKE_reportf(reports, RPT_ERROR, "Cannot save blend file, path '%s' is not writable", filepath);
|
||||
return ret;
|
||||
return ok;
|
||||
}
|
||||
|
||||
/* note: used to replace the file extension (to ensure '.blend'),
|
||||
@@ -1222,7 +1222,7 @@ static int wm_file_write(bContext *C, const char *filepath, int fileflags, Repor
|
||||
for (li = bmain->library.first; li; li = li->id.next) {
|
||||
if (BLI_path_cmp(li->filepath, filepath) == 0) {
|
||||
BKE_reportf(reports, RPT_ERROR, "Cannot overwrite used library '%.240s'", filepath);
|
||||
return ret;
|
||||
return ok;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1284,7 +1284,8 @@ static int wm_file_write(bContext *C, const char *filepath, int fileflags, Repor
|
||||
ibuf_thumb = IMB_thumb_create(filepath, THB_LARGE, THB_SOURCE_BLEND, ibuf_thumb);
|
||||
}
|
||||
|
||||
ret = 0; /* Success. */
|
||||
/* Success. */
|
||||
ok = true;
|
||||
}
|
||||
|
||||
if (ibuf_thumb) {
|
||||
@@ -1296,7 +1297,7 @@ static int wm_file_write(bContext *C, const char *filepath, int fileflags, Repor
|
||||
|
||||
WM_cursor_wait(0);
|
||||
|
||||
return ret;
|
||||
return ok;
|
||||
}
|
||||
|
||||
/************************ autosave ****************************/
|
||||
@@ -1473,6 +1474,7 @@ void WM_file_tag_modified(void)
|
||||
|
||||
/**
|
||||
* \see #wm_file_write wraps #BLO_write_file in a similar way.
|
||||
* \return success.
|
||||
*/
|
||||
static int wm_homefile_write_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
@@ -2166,7 +2168,6 @@ static int wm_save_as_mainfile_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
Main *bmain = CTX_data_main(C);
|
||||
char path[FILE_MAX];
|
||||
int fileflags, orig_fileflags;
|
||||
const bool is_save_as = (op->type->invoke == wm_save_as_mainfile_invoke);
|
||||
|
||||
save_set_compress(op);
|
||||
@@ -2179,8 +2180,8 @@ 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;
|
||||
const int fileflags_orig = G.fileflags;
|
||||
int fileflags = G.fileflags & ~G_FILE_USERPREFS;
|
||||
|
||||
/* set compression flag */
|
||||
SET_FLAG_FROM_TEST(
|
||||
@@ -2195,16 +2196,16 @@ static int wm_save_as_mainfile_exec(bContext *C, wmOperator *op)
|
||||
RNA_boolean_get(op->ptr, "copy")),
|
||||
G_FILE_SAVE_COPY);
|
||||
|
||||
int write_result = wm_file_write(C, path, fileflags, op->reports);
|
||||
const bool ok = 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;
|
||||
G.fileflags = fileflags_orig;
|
||||
}
|
||||
|
||||
if (write_result != 0) {
|
||||
if (ok == false) {
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user