Even though I was worried that this would break saving default session when all its files get closed and then a project is loaded, it doesn't seem to be the case (I haven't investigated deep enough why).
The reason why this doesn't happen is the default ``` save_config_on_file_change=TRUE ``` When disabled, the problem happens. I.e.: 1. With project closed, open some files. 2. Restart Geany to make sure the files from (1) are stored in the default session 3. Close all of the open files 4. Open a project 5. Close the project 6. The open files from (1) are restored but, instead, there should be no open files because of (3)
So this patch is trading one problem for another, but IMO still worth it because the second problem is much more rare.
Even though I suggested passing some boolean in the description above, this affects several session management functions at various places and makes the already complicated code even worse so I'd prefer the slightly buggy approach from this PR.
In the future, I think the best solution would be rewriting the session management from scratch, moving it to a separate file and making sure its API would abstract-away the callers from details of what state the session is in.