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:
authorAndrea Weikert <elubie@gmx.net>2010-04-15 00:45:36 +0400
committerAndrea Weikert <elubie@gmx.net>2010-04-15 00:45:36 +0400
commita02a4f0fc4ae16ffc66b3a1efc9c3f649ac11acc (patch)
tree1ec1deb06162aec2eef0e4f5114f6310956c2c09 /source/blender
parent72a73fc9fbbbf0496166be3ec623f722f1836530 (diff)
fix [#22007] Saving a read-only file on windows : no warning and temporary files left there
* small improvement to last commit: actually pass the error value from WM_write_file back to the operator and cancel the operator if not successful. This also preserves the indication that the file hasn't been saved in case of error.
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/windowmanager/WM_api.h2
-rw-r--r--source/blender/windowmanager/intern/wm_files.c9
-rw-r--r--source/blender/windowmanager/intern/wm_operators.c5
3 files changed, 10 insertions, 6 deletions
diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h
index c005fd5828c..889b261dc41 100644
--- a/source/blender/windowmanager/WM_api.h
+++ b/source/blender/windowmanager/WM_api.h
@@ -78,7 +78,7 @@ void WM_window_open_temp (struct bContext *C, struct rcti *position, int type);
int WM_read_homefile (struct bContext *C, struct wmOperator *op);
int WM_write_homefile (struct bContext *C, struct wmOperator *op);
void WM_read_file (struct bContext *C, char *name, struct ReportList *reports);
-void WM_write_file (struct bContext *C, char *target, int fileflags, struct ReportList *reports);
+int WM_write_file (struct bContext *C, char *target, int fileflags, struct ReportList *reports);
void WM_read_autosavefile(struct bContext *C);
void WM_autosave_init (struct wmWindowManager *wm);
diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c
index 3c7548fb39f..7e309b9c876 100644
--- a/source/blender/windowmanager/intern/wm_files.c
+++ b/source/blender/windowmanager/intern/wm_files.c
@@ -483,7 +483,7 @@ static void do_history(char *name, ReportList *reports)
BKE_report(reports, RPT_ERROR, "Unable to make version backup");
}
-void WM_write_file(bContext *C, char *target, int fileflags, ReportList *reports)
+int WM_write_file(bContext *C, char *target, int fileflags, ReportList *reports)
{
Library *li;
int len;
@@ -494,14 +494,14 @@ void WM_write_file(bContext *C, char *target, int fileflags, ReportList *reports
if (len == 0) return;
if (len >= FILE_MAX) {
BKE_report(reports, RPT_ERROR, "Path too long, cannot save");
- return;
+ return -1;
}
/* send the OnSave event */
for (li= G.main->library.first; li; li= li->id.next) {
if (BLI_streq(li->name, target)) {
BKE_report(reports, RPT_ERROR, "Cannot overwrite used library");
- return;
+ return -1;
}
}
@@ -539,9 +539,12 @@ void WM_write_file(bContext *C, char *target, int fileflags, ReportList *reports
else G.fileflags &= ~G_FILE_AUTOPLAY;
writeBlog();
+ } else {
+ return -1;
}
// XXX waitcursor(0);
+ return 0;
}
/* operator entry */
diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c
index 09f923a15f5..2e9da9f7d1c 100644
--- a/source/blender/windowmanager/intern/wm_operators.c
+++ b/source/blender/windowmanager/intern/wm_operators.c
@@ -1792,8 +1792,9 @@ static int wm_save_as_mainfile_exec(bContext *C, wmOperator *op)
if(RNA_boolean_get(op->ptr, "relative_remap")) fileflags |= G_FILE_RELATIVE_REMAP;
else fileflags &= ~G_FILE_RELATIVE_REMAP;
- WM_write_file(C, path, fileflags, op->reports);
-
+ if ( WM_write_file(C, path, fileflags, op->reports) != 0)
+ return OPERATOR_CANCELLED;
+
WM_event_add_notifier(C, NC_WM|ND_FILESAVE, NULL);
return OPERATOR_FINISHED;