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.
This commit is contained in:
Campbell Barton 2010-09-17 08:53:39 +00:00
parent b9a3da9080
commit 945ae25409
2 changed files with 10 additions and 15 deletions

@ -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);

@ -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);
}