I certainly did not intend to discourage anyone from contributing to the project.
Seeking out these bugs and new ideas are most welcome.
That's good to hear, although it has not been my experience so far and reading posts elsewhere in the forum I am not alone. Note, I am talking about this forum as a whole, as previously noted. Therefore, as I do have other things I need to get on with, I hope the time I've taken to write up the following has not been wasted.
There are three events I found to trigger a save of the keyboard shortcuts:- User Configuration Dialogue, Shutdown of Codeblocks and some external change that can only be detected by the 15sec timer (see post above by Pecan). I have tested each of these triggers and compared the resulting files for differences and found the only time the tools items configuration is written incorrectly is when shutting down codeblocks.. I believe the reason for this is the operation to scan through and parse every menu item takes a long time and codeblocks starts to delete it's tools menu before keybinder has finished enumerating it - in other words, codeblocks does not seem to wait for it's plugins to exit before it starts to shut itself down (although it may well wait before actually terminating, that's not the issue here).
Removing the save within cbKeyBinder::OnRelease makes for a tools menu that is fully saved and restored - every time. Although not ideal it is a good enough workaround as most changes are done through the configuration, those that aren't will be caught by the timer so I guess the only danger is something unknown adding a shortcut just before shutting down. However, that'll likely be a plugin so it'll restore it on it's own when reloaded? Stop me if I'm completely wrong but it seems to work well here and I've changed a lot of the standard, plugin and tools shortcut items.
Anyway, based on the above I hope we can see this is a timing issue and will most likely require a change in the CodeBlocks source to rectify properly. I'm sure there is some 'hacky' workaround that forces codeblocks to wait but that would be unpleasant and not too useful to other plugins this could potentially effect. I hope someone familiar with the guts of CodeBlocks will check this issue and confirm either way.
Btw, it's not just the tools items that are affected. The following entries are potentially lost along with the tools items when saving on exit. The second item would suggest it's not just the tools menu being removed prematurely...
- bind121-type4660=Configure tools...|Add/remove user-defined tools|
- bind925-type4660=Complete code||Ctrl-SPACE|
Also, a similar problem unrelated to the above... The entries below are lost when a save is triggered at the same time as their parent menu, 'Select Target..' is greyed out. Neither can you configure these shortcuts when their parent menu is disabled. This behaviour is inconsistent with other parent menus and their children such as those under the 'Edit' menu ('Folding', 'Special Commands' etc.). I think it's just some special processing needed that's been overlooked for this one.
- bind1481-type4660=All|Build target 'All' in current project|
- bind1482-type4660=default|Build target 'default' in current project|
One more thing I've noticed (before I get thrown out!) is that the context menu for the 'Projects' tab is never updated to reflect current keyboard shortcuts (move project up/down etc.), although they work and the same items in the main menu are correct.
PS: it's taken me (much) longer to write this than it took to test it all out - so when my (or anybody else's) effort is dismissed without proper consideration it's understandably discouraging, as well as frustrating!When the Tools menu is modified in the background, it is always rebuilt without its shortcuts. KeyBinder will slowly record this fact.
This is a separate and less annoying issue to the one I first posted about as it can at least be worked around. There are two solutions to it though: detect the 'Configure Tools' dialog and perform a restore of the items that still match (I notice keybinder already detects new windows so it shouldn't be hard), this would be a bit of a hack though. The preferred solution is codeblocks should only need to delete/insert/modify items as needed and can check if a shortcut is assigned beforehand and restore it (eg. if a caption is being changed). This is certainly the case on windows anyway - there is no need to rebuild from scratch each time. I'd look into creating a patch to do this if I had any faith it would be accepted and my effort wouldn't be wasted.
If you want to progress with any of the above then I am willing to help.
Jamie