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:
Diffstat (limited to 'source/blender/windowmanager/intern/wm_files.c')
-rw-r--r--source/blender/windowmanager/intern/wm_files.c85
1 files changed, 44 insertions, 41 deletions
diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c
index 8a05e6c4916..e2293f79e95 100644
--- a/source/blender/windowmanager/intern/wm_files.c
+++ b/source/blender/windowmanager/intern/wm_files.c
@@ -179,21 +179,23 @@ static void wm_window_match_do(bContext *C, ListBase *oldwmlist)
/* we've read file without wm..., keep current one entirely alive */
if(G.main->wm.first==NULL) {
- bScreen *screen= CTX_wm_screen(C);
-
- /* match oldwm to new dbase, only old files */
-
- for(wm= oldwmlist->first; wm; wm= wm->id.next) {
-
- for(win= wm->windows.first; win; win= win->next) {
- /* all windows get active screen from file */
- if(screen->winid==0)
- win->screen= screen;
- else
- win->screen= ED_screen_duplicate(win, screen);
+ /* when loading without UI, no matching needed */
+ if(!(G.fileflags & G_FILE_NO_UI)) {
+ bScreen *screen= CTX_wm_screen(C);
+
+ /* match oldwm to new dbase, only old files */
+ for(wm= oldwmlist->first; wm; wm= wm->id.next) {
- BLI_strncpy(win->screenname, win->screen->id.name+2, 21);
- win->screen->winid= win->winid;
+ for(win= wm->windows.first; win; win= win->next) {
+ /* all windows get active screen from file */
+ if(screen->winid==0)
+ win->screen= screen;
+ else
+ win->screen= ED_screen_duplicate(win, screen);
+
+ BLI_strncpy(win->screenname, win->screen->id.name+2, 21);
+ win->screen->winid= win->winid;
+ }
}
}
@@ -312,7 +314,7 @@ void WM_read_file(bContext *C, char *name, ReportList *reports)
CTX_wm_window_set(C, CTX_wm_manager(C)->windows.first);
ED_editors_init(C);
- DAG_on_load_update();
+ DAG_on_load_update(CTX_data_main(C));
#ifndef DISABLE_PYTHON
/* run any texts that were loaded in and flagged as modules */
@@ -382,7 +384,7 @@ int WM_read_homefile(bContext *C, wmOperator *op)
/* XXX */
G.save_over = 0; // start with save preference untitled.blend
- G.fileflags &= ~G_FILE_AUTOPLAY; /* disable autoplay in .B.blend... */
+ G.fileflags &= ~G_FILE_AUTOPLAY; /* disable autoplay in startup.blend... */
// mainwindow_set_filename_to_title(""); // empty string re-initializes title to "Blender"
// refresh_interface_font();
@@ -392,7 +394,7 @@ int WM_read_homefile(bContext *C, wmOperator *op)
BKE_write_undo(C, "original"); /* save current state */
ED_editors_init(C);
- DAG_on_load_update();
+ DAG_on_load_update(CTX_data_main(C));
WM_event_add_notifier(C, NC_WM|ND_FILEREAD, NULL);
CTX_wm_window_set(C, NULL); /* exits queues */
@@ -418,7 +420,7 @@ void read_history(void)
G.recent_files.first = G.recent_files.last = NULL;
- /* read list of recent opend files from .Blog to memory */
+ /* read list of recent opend files from recent-files.txt to memory */
for (l= lines, num= 0; l && (num<U.recent_files); l= l->next) {
line = l->link;
if (line[0] && BLI_exists(line)) {
@@ -434,9 +436,6 @@ void read_history(void)
num++;
}
}
-
- if(G.sce[0] == 0)
- BLI_make_file_string("/", G.sce, BLI_gethome(), "untitled.blend");
BLI_free_file_lines(lines);
@@ -452,7 +451,7 @@ static void write_history(void)
BLI_make_file_string("/", name, BLI_get_folder_create(BLENDER_USER_CONFIG, NULL), BLENDER_HISTORY_FILE);
recent = G.recent_files.first;
- /* refresh .Blog of recent opened files, when current file was changed */
+ /* refresh recent-files.txt of recent opened files, when current file was changed */
if(!(recent) || (strcmp(recent->filepath, G.sce)!=0)) {
fp= fopen(name, "w");
if (fp) {
@@ -462,11 +461,11 @@ static void write_history(void)
recent->filepath[0] = '\0';
strcpy(recent->filepath, G.sce);
BLI_addhead(&(G.recent_files), recent);
- /* write current file to .Blog */
+ /* write current file to recent-files.txt */
fprintf(fp, "%s\n", recent->filepath);
recent = recent->next;
i=1;
- /* write rest of recent opened files to .Blog */
+ /* write rest of recent opened files to recent-files.txt */
while((i<U.recent_files) && (recent)){
/* this prevents to have duplicities in list */
if (strcmp(recent->filepath, G.sce)!=0) {
@@ -569,7 +568,7 @@ int write_crash_blend(void)
}
}
-int WM_write_file(bContext *C, char *target, int fileflags, ReportList *reports)
+int WM_write_file(bContext *C, char *target, int fileflags, ReportList *reports, int copy)
{
Library *li;
int len;
@@ -616,17 +615,20 @@ int WM_write_file(bContext *C, char *target, int fileflags, ReportList *reports)
ED_object_exit_editmode(C, EM_DO_UNDO);
ED_sculpt_force_update(C);
- do_history(di, reports);
-
/* blend file thumbnail */
ibuf_thumb= blend_file_thumb(di, CTX_data_scene(C), &thumb);
- if (BLO_write_file(CTX_data_main(C), di, fileflags, reports, thumb)) {
- strcpy(G.sce, di);
- G.relbase_valid = 1;
- strcpy(G.main->name, di); /* is guaranteed current file */
+ /* rename to .blend1, do this as last before write */
+ do_history(di, reports);
- G.save_over = 1; /* disable untitled.blend convention */
+ if (BLO_write_file(CTX_data_main(C), di, fileflags, reports, thumb)) {
+ if(!copy) {
+ strcpy(G.sce, di);
+ G.relbase_valid = 1;
+ strcpy(G.main->name, di); /* is guaranteed current file */
+
+ G.save_over = 1; /* disable untitled.blend convention */
+ }
if(fileflags & G_FILE_COMPRESS) G.fileflags |= G_FILE_COMPRESS;
else G.fileflags &= ~G_FILE_COMPRESS;
@@ -685,21 +687,22 @@ void wm_autosave_location(char *filename)
{
char pidstr[32];
#ifdef WIN32
- char subdir[9];
- char savedir[FILE_MAXDIR];
+ char *savedir;
#endif
sprintf(pidstr, "%d.blend", abs(getpid()));
#ifdef WIN32
+ /* XXX Need to investigate how to handle default location of '/tmp/'
+ * This is a relative directory on Windows, and it may be
+ * found. Example:
+ * Blender installed on D:\ drive, D:\ drive has D:\tmp\
+ * Now, BLI_exists() will find '/tmp/' exists, but
+ * BLI_make_file_string will create string that has it most likely on C:\
+ * through get_default_root().
+ * If there is no C:\tmp autosave fails. */
if (!BLI_exists(U.tempdir)) {
- BLI_strncpy(subdir, "autosave", sizeof(subdir));
- BLI_make_file_string("/", savedir, BLI_gethome(), subdir);
-
- /* create a new autosave dir
- * function already checks for existence or not */
- BLI_recurdir_fileops(savedir);
-
+ savedir = BLI_get_folder_create(BLENDER_USER_AUTOSAVE, NULL);
BLI_make_file_string("/", filename, savedir, pidstr);
return;
}