Currently when building a project, all modified open files in that project are saved first.
However, the project itself may be modified but is not saved to disk.
This causes a raft of problems - if someone forgets to explicitly save the project, they often forget to check in their changes to revision control, thinking that everything they've changed has been saved because all other files have been saved. Changes are also often lost when code::blocks crashes, because the project isn't saved automatically until a clean exit. Furthermore, a number of build tools and scripts parse the project file externally, and in this scenario find it to be inconsistent with what code::blocks is doing.
I request that the project is set to automatically save, if modified, when a build begins, in the same way that all modified files are saved at that point.
I too think this is a good idea...
I have made two patches:
Save_project_before_build_ask
This patch asks for saving the project. It uses an annoyingdialog so the user can save the decision. So the old behaviour is easily reproducibly by simply saving the NO option...
Save_project_before_build
This patch simply saves the project and does not ask
second patch
[deleted, because of double post]
Last edit: bluehazzard 2016-11-12
push!!!
I lost right now a lot project settings because c::b didn't saved on
build and crashed afterwards....
I've developed almost a nervous tick now, I compulsively right-click and save project every time I make even the most trivial change to it, because of this issue...
I also see this issue, especially in some times when I use git to manage both the cbp and cpp files, I first see some cpp files were changed and commited to git repo, and later, I see the cbp is not changed yet(because C::B sometimes crashes). I think your patch is great!
Have you tried to inspect why C::B crashes?
Have you tried the autosave plugin (I know it is not great, but I'm using it and I've never lost a setting due to crashes)?
Also which of the two patches should be pushed/applied?
was an one time crash, something with wx3.x on linux, i was not able to reproduce, but i run c::b trough the debugger full time...
i always used it, but i forget to activate on my new installation. Shame on me. But i think: if all source files are saved also the project file should be saved, it is a essential part of the build process...
I would prefer Save_project_before_build.patch because it is simple and does its stuff, but with [1] in mind you can also use patch 2, where the user has the decision
[1] https://xkcd.com/1172/
CodeCompletion plugin will run a full parse(parse all the source files) when the cbp file is saved.
ollydbg: What do you want to say with this cc statement? Is this going to cause a problem if the patch is applied?
I mean if this patch is applied, then one hits the build button, both the compiler and cc plugin will start to work, and the cpu usage will be quite high.
Last edit: ollydbg 2016-11-14
So add a lock / delay of some kind to prevent the project reloading until the compile has completed, or give that process minimal priority. Alternatively simply don't have the project re-parse on save, have it re-parse on load or some other trigger instead. These are all non-issues really; if someone is compiling C++ (and my typical compile times run from tens of seconds to tens of minutes, depending on machine), then worrying about "cpu usage being quite high" is nonsensical - it should be 100% in any case. In terms of adding extra time, a few hundred milliseconds to re-parse the project is not going to be significant; certainly not compared to the impact of having to repeat changes you've lost because of CB's frequent crashes - and I have to pay that anyway when I manually click for the project to save just before I build anyway, it just costs me more time by having to make two more clicks.
I agree with you. I think a simple solution is: just disable "re-parse" on save. Because CC does not cache the build options, I mean, if I add a new library to the cbp file, then save the cbp, CC should not reparse the project(as it just waste of time to parse the project again, but nothing changes on the reparse).
So, if you guys agree on appling bluehazzard's patch, I think I will disable the "reparse on save" feature on CC plugin.
This issue has been open for a long time now, but I've just thought of a neat workaround using codeblocks scripting.
Simply add the following to the pre-build steps for the project:
[[ GetProjectManager().SaveAllProjects(); ]]
And voila, all open projects will be saved when the selected one is built.
++