Maybe the session should be saved before opening a project (at step 2 in the OP or step 4 above) so the right thing can be restored after?
The trouble with this session management code is that it gets called from many different places and on different occasions so the "before opening project" place is e.g. at
recent_project_activate_cb()
in ui_utils.c
run_open_dialog()
in project.c
and then you'd have to add big fat comments regarding why you are placing the saving there and not in project opening itself. Also, this would lead to a double-save for sessions where you don't close all files before loading a project.
As I said, I think the whole session management should be rewritten but that's a major task.
Although on thinking about it, why wasn't the session saved at step 3 above?
Notice what this patch does for project opens:
if (have_session_docs()) // <-- the patch adds this check
configuration_save_default_session();
This is called in two cases:
open project session -> open project session
transition where the current code saves the empty session after closing the first project.default session -> open project session
where the default session really doesn't contain any file and you want to save the "no open file" state. This patch breaks it.Note that (2) will break only for the case when both of these conditions are satisfied:
save_config_on_file_change
is disabled (which is not by default)Since I think this behavior is much less problematic than losing the whole session and it is rather hard to trigger, I think it's an acceptable workaround until someone decides to rewrite the session management code from scratch.
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.