bugfix [#23456] context.main.filepath lost after undo

G.sce was being restored after undo but not G.main->name
 also changed reading a new file so G.main->name gets set to the startup.blend even if its not on the disk, not ideal but would set to <memory2> otherwise.
This commit is contained in:
Campbell Barton
2010-08-25 04:03:38 +00:00
parent 8ffc50e45c
commit b54d16858f
2 changed files with 11 additions and 3 deletions

View File

@@ -460,13 +460,16 @@ static UndoElem *curundo= NULL;
static int read_undosave(bContext *C, UndoElem *uel)
{
char scestr[FILE_MAXDIR+FILE_MAXFILE];
char scestr[FILE_MAXDIR+FILE_MAXFILE]; /* we should eventually just use G.main->name */
char mainstr[FILE_MAXDIR+FILE_MAXFILE];
int success=0, fileflags;
/* This is needed so undoing/redoing doesnt crash with threaded previews going */
WM_jobs_stop_all(CTX_wm_manager(C));
strcpy(scestr, G.sce); /* temporal store */
strcpy(mainstr, G.main->name); /* temporal store */
fileflags= G.fileflags;
G.fileflags |= G_FILE_NO_UI;
@@ -476,7 +479,8 @@ static int read_undosave(bContext *C, UndoElem *uel)
success= BKE_read_file_from_memfile(C, &uel->memfile, NULL);
/* restore */
strcpy(G.sce, scestr);
strcpy(G.sce, scestr); /* restore */
strcpy(G.main->name, mainstr); /* restore */
G.fileflags= fileflags;
if(success)

View File

@@ -334,6 +334,9 @@ void WM_read_file(bContext *C, char *name, ReportList *reports)
/* called on startup, (context entirely filled with NULLs) */
/* or called for 'New File' */
/* op can be NULL */
/* note: G.sce is used to store the last saved path so backup and restore after loading
* G.main->name is similar to G.sce but when loading from memory set the name to startup.blend
* ...this could be changed but seems better then setting to "" */
int WM_read_homefile(bContext *C, wmOperator *op)
{
ListBase wmbase;
@@ -376,7 +379,8 @@ int WM_read_homefile(bContext *C, wmOperator *op)
WM_check(C); /* opens window(s), checks keymaps */
strcpy(G.sce, scestr); /* restore */
strcpy(G.main->name, tstr); /* this is wrong when loading from memory but better then leaving as-is */
wm_init_userdef(C);
/* When loading factory settings, the reset solid OpenGL lights need to be applied. */