bug fix, when opening blender with a file (by double clicking or from the command line) - the initial undo state would be set to the default scene.

So holding Ctrl+Z would go back to the default .B.blend rather then the file that the user opened.
This commit is contained in:
Campbell Barton 2007-10-23 21:31:59 +00:00
parent 7fc1297b3c
commit 5b0a79c7c7
6 changed files with 17 additions and 10 deletions

@ -43,7 +43,7 @@ void exit_usiblender(void);
void BIF_init(void);
void BIF_read_file(char *name);
int BIF_read_homefile(int from_memory);
int BIF_read_homefile(int from_memory, int do_undo);
void BIF_read_autosavefile(void);
void BIF_write_file(char *target);

@ -637,7 +637,7 @@ static PyObject *Blender_Load( PyObject * self, PyObject * args )
* enough here. Note: the default file requires extra clean-up done by
* BIF_read_homefile: freeing the user theme data. */
if( !fname || ( strstr( fname, ".B.blend" ) && is_blend_file ) )
BIF_read_homefile(0);
BIF_read_homefile(0, 1);
else
BIF_read_file( fname );

@ -812,7 +812,7 @@ static void do_info_filemenu(void *arg, int event)
switch(event) {
case 0:
if (okee("Erase All")) {
if (!BIF_read_homefile(0))
if (!BIF_read_homefile(0, 1))
error("No file ~/.B.blend");
}
break;
@ -896,7 +896,7 @@ static void do_info_filemenu(void *arg, int event)
break;
case 32:
if (okee("Erase All")) {
if (!BIF_read_homefile(1))
if (!BIF_read_homefile(1, 1))
error("Can't read data from memory!");
}
break;

@ -942,7 +942,7 @@ int blenderqread(unsigned short event, short val)
if(textspace==0 && textediting==0) {
if(G.qual==LR_CTRLKEY) {
if(okee("Erase all")) {
if( BIF_read_homefile(0)==0) error("No file ~/.B.blend");
if( BIF_read_homefile(0, 1)==0) error("No file ~/.B.blend");
}
return 0;
}

@ -483,7 +483,7 @@ static void outliner_242_patch(void)
}
/* only here settings for fullscreen */
int BIF_read_homefile(int from_memory)
int BIF_read_homefile(int from_memory, int do_undo)
{
char tstr[FILE_MAXDIR+FILE_MAXFILE], scestr[FILE_MAXDIR];
char *home= BLI_gethome();
@ -526,7 +526,9 @@ int BIF_read_homefile(int from_memory)
undo_editmode_clear();
BKE_reset_undo();
BKE_write_undo("original"); /* save current state */
if (do_undo)
BIF_undo_push("original");
return success;
}
@ -896,7 +898,11 @@ void BIF_init(void)
init_node_butfuncs();
BIF_preview_init_dbase();
BIF_read_homefile(0);
/* dont set an undo here because this sets the default scene to be the initial
undo state when loading blender with a file a new file, so holding Ctrl+Z will undo to the default
scene rather then to the new file */
BIF_read_homefile(0, 0);
BIF_resources_init(); /* after homefile, to dynamically load an icon file based on theme settings */

@ -703,6 +703,7 @@ int main(int argc, char **argv)
set_scene(sce);
}
BKE_write_undo("original"); /* save current state */
screenmain();
return 0;