fix for loosing recent-files when running 'Copy Previous Settings'.

This commit is contained in:
Campbell Barton 2013-03-28 02:29:10 +00:00
parent eab20832d9
commit 0237e7eef2
4 changed files with 26 additions and 1 deletions

@ -1273,11 +1273,15 @@ class WM_OT_copy_prev_settings(Operator):
else:
shutil.copytree(path_src, path_dst, symlinks=True)
# reload recent-files.txt
bpy.ops.wm.read_history()
# don't loose users work if they open the splash later.
if bpy.data.is_saved is bpy.data.is_dirty is False:
bpy.ops.wm.read_homefile()
else:
self.report({'INFO'}, "Reload Start-Up file to restore settings")
return {'FINISHED'}
return {'CANCELLED'}

@ -602,6 +602,13 @@ int wm_homefile_read(bContext *C, ReportList *UNUSED(reports), short from_memory
return TRUE;
}
int wm_history_read_exec(bContext *UNUSED(C), wmOperator *UNUSED(op))
{
/* TODO, read bookmarks */
wm_read_history();
return OPERATOR_FINISHED;
}
int wm_homefile_read_exec(bContext *C, wmOperator *op)
{
int from_memory = strcmp(op->type->idname, "WM_OT_read_factory_settings") == 0;
@ -637,7 +644,6 @@ void wm_read_history(void)
}
BLI_file_free_lines(lines);
}
static void write_history(void)

@ -1906,6 +1906,19 @@ static void WM_OT_save_userpref(wmOperatorType *ot)
ot->poll = WM_operator_winactive;
}
static void WM_OT_read_history(wmOperatorType *ot)
{
ot->name = "Reload History File";
ot->idname = "WM_OT_read_history";
ot->description = "Reloads history and bookmarks";
ot->invoke = WM_operator_confirm;
ot->exec = wm_history_read_exec;
/* this operator is only used for loading settings from a previous blender install */
ot->flag = OPTYPE_INTERNAL;
}
static void WM_OT_read_homefile(wmOperatorType *ot)
{
ot->name = "Reload Start-Up File";
@ -4043,6 +4056,7 @@ void wm_operatortype_init(void)
global_ops_hash = BLI_ghash_str_new("wm_operatortype_init gh");
WM_operatortype_append(WM_OT_window_duplicate);
WM_operatortype_append(WM_OT_read_history);
WM_operatortype_append(WM_OT_read_homefile);
WM_operatortype_append(WM_OT_read_factory_settings);
WM_operatortype_append(WM_OT_save_homefile);

@ -33,6 +33,7 @@
void wm_read_history(void);
int wm_file_write(struct bContext *C, const char *target, int fileflags, struct ReportList *reports);
int wm_history_read_exec(bContext *C, wmOperator *op);
int wm_homefile_read_exec(struct bContext *C, struct wmOperator *op);
int wm_homefile_read(struct bContext *C, struct ReportList *reports, short from_memory);
int wm_homefile_write_exec(struct bContext *C, struct wmOperator *op);