diff options
author | Campbell Barton <ideasman42@gmail.com> | 2010-09-17 12:53:39 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2010-09-17 12:53:39 +0400 |
commit | 945ae254092dcbb284072fd4ffcc80b33bff27f6 (patch) | |
tree | 629df0afa94bc64dc8870f9e717df77e2b1c6ea5 | |
parent | b9a3da908036a16c0f140a894d96d60e1eb5edaf (diff) |
fix for some errors when saving blend files.
- when comparing with libraries, relative paths were used which could easily fail.
- testing libraries was done before adding the .blend extension.
-rw-r--r-- | source/blender/windowmanager/WM_api.h | 2 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_files.c | 23 |
2 files changed, 10 insertions, 15 deletions
diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h index d04e08eda14..690d8ad0f75 100644 --- a/source/blender/windowmanager/WM_api.h +++ b/source/blender/windowmanager/WM_api.h @@ -80,7 +80,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); -int WM_write_file (struct bContext *C, char *target, int fileflags, struct ReportList *reports, int copy); +int WM_write_file (struct bContext *C, const char *target, int fileflags, struct ReportList *reports, int copy); 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 038270ae58a..f0b8577be47 100644 --- a/source/blender/windowmanager/intern/wm_files.c +++ b/source/blender/windowmanager/intern/wm_files.c @@ -585,7 +585,7 @@ int write_crash_blend(void) } } -int WM_write_file(bContext *C, char *target, int fileflags, ReportList *reports, int copy) +int WM_write_file(bContext *C, const char *target, int fileflags, ReportList *reports, int copy) { Library *li; int len; @@ -606,25 +606,20 @@ int WM_write_file(bContext *C, char *target, int fileflags, ReportList *reports, return -1; } + BLI_strncpy(di, target, FILE_MAX); + BLI_replace_extension(di, FILE_MAX, ".blend"); + /* dont use 'target' anymore */ + /* 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"); + if (strcmp(li->filepath, di) == 0) { + BKE_reportf(reports, RPT_ERROR, "Can't overwrite used library '%f'", di); return -1; } } - - if (!BLO_has_bfile_extension(target) && (len+6 < FILE_MAX)) { - sprintf(di, "%s.blend", target); - } else { - strcpy(di, target); - } -// if (BLI_exists(di)) { -// XXX if(!saveover(di)) -// XXX return; -// } - + /* operator now handles overwrite checks */ + if (G.fileflags & G_AUTOPACK) { packAll(G.main, reports); } |