From d867cefa32ca3b26bbfc279e2f04d4f795dc13a4 Mon Sep 17 00:00:00 2001 From: Ton Roosendaal Date: Sat, 13 Apr 2013 12:03:20 +0000 Subject: Bug fix #34896 The feature "Keep Session" was also loading that session when you double-click on a .blend to open it, or when a .blend file was on commandline. Moved this feature to the main() in creator.c, so it can check on it properly, skipping the kept session when a file was loaded. --- source/blender/windowmanager/WM_api.h | 1 + source/blender/windowmanager/intern/wm_init_exit.c | 3 ++- source/blender/windowmanager/intern/wm_operators.c | 4 ++-- source/blender/windowmanager/wm_event_system.h | 3 --- source/creator/creator.c | 12 ++++++++++++ 5 files changed, 17 insertions(+), 6 deletions(-) diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h index 9e6a483aa76..6048fe030b8 100644 --- a/source/blender/windowmanager/WM_api.h +++ b/source/blender/windowmanager/WM_api.h @@ -113,6 +113,7 @@ bool WM_is_draw_triple(struct wmWindow *win); /* files */ void WM_file_read(struct bContext *C, const char *filepath, struct ReportList *reports); void WM_autosave_init(struct wmWindowManager *wm); +void WM_recover_last_session(struct bContext *C, struct ReportList *reports); /* mouse cursors */ void WM_cursor_set (struct wmWindow *win, int curs); diff --git a/source/blender/windowmanager/intern/wm_init_exit.c b/source/blender/windowmanager/intern/wm_init_exit.c index ccb463e59cb..9810d1ecf72 100644 --- a/source/blender/windowmanager/intern/wm_init_exit.c +++ b/source/blender/windowmanager/intern/wm_init_exit.c @@ -223,7 +223,8 @@ void WM_init(bContext *C, int argc, const char **argv) /* load last session, uses regular file reading so it has to be in end (after init py etc) */ if (U.uiflag2 & USER_KEEP_SESSION) { - wm_recover_last_session(C, NULL); + /* calling WM_recover_last_session(C, NULL) has been moved to creator.c */ + /* that prevents loading both the kept session, and the file on the command line */ } else { /* normally 'wm_homefile_read' will do this, diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index 8f741402154..8b7073c2c65 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -2237,7 +2237,7 @@ static void WM_OT_link_append(wmOperatorType *ot) /* *************** recover last session **************** */ -void wm_recover_last_session(bContext *C, ReportList *reports) +void WM_recover_last_session(bContext *C, ReportList *reports) { char filename[FILE_MAX]; @@ -2268,7 +2268,7 @@ void wm_recover_last_session(bContext *C, ReportList *reports) static int wm_recover_last_session_exec(bContext *C, wmOperator *op) { - wm_recover_last_session(C, op->reports); + WM_recover_last_session(C, op->reports); return OPERATOR_FINISHED; } diff --git a/source/blender/windowmanager/wm_event_system.h b/source/blender/windowmanager/wm_event_system.h index d12e1d47fa0..cc139f33c84 100644 --- a/source/blender/windowmanager/wm_event_system.h +++ b/source/blender/windowmanager/wm_event_system.h @@ -104,8 +104,5 @@ void wm_dropbox_free(void); void wm_drags_check_ops(bContext *C, wmEvent *event); void wm_drags_draw(bContext *C, wmWindow *win, rcti *rect); -/* wm_operators.c */ -void wm_recover_last_session(bContext *C, ReportList *reports); - #endif /* __WM_EVENT_SYSTEM_H__ */ diff --git a/source/creator/creator.c b/source/creator/creator.c index cea32a8b171..aecff4c9e03 100644 --- a/source/creator/creator.c +++ b/source/creator/creator.c @@ -1196,6 +1196,11 @@ static int set_addons(int argc, const char **argv, void *data) } } +static int test_file(int UNUSED(argc), const char **argv, void *data) +{ + printf("path is %s\n", argv[0]); +} + static int load_file(int UNUSED(argc), const char **argv, void *data) { bContext *C = data; @@ -1604,6 +1609,13 @@ int main(int argc, const char **argv) /* OK we are ready for it */ #ifndef WITH_PYTHON_MODULE BLI_argsParse(ba, 4, load_file, C); + + if (G.background == 0) { + if (!G.file_loaded) + if (U.uiflag2 & USER_KEEP_SESSION) + WM_recover_last_session(C, NULL); + } + #endif #ifndef WITH_PYTHON_MODULE -- cgit v1.2.3