Code::Blocks

Developer forums (C::B DEVELOPMENT STRICTLY!) => Plugins development => Topic started by: oBFusCATed on June 27, 2019, 07:23:34 pm

Title: Keybinder v2 notes/problems
Post by: oBFusCATed on June 27, 2019, 07:23:34 pm
I've updated my main install of the codeblocks to the latest rev and the keybinder seems to be broken for me.
Here is the list of things I've spotted as problems:

1. Memory leak from "m_pAccelEntries = new wxAcceleratorEntry[m_AccelCount];" use unique_ptr?
2. ctrl-shift-. and ctrl-shift-t doesn't work as accelerators
3. The new keybinder failed to parse the old config and lost all my bindings
4. The old menu name is not visible on windows7 with wx-master + 4k 27inch display in the settings on windows (this is with the latest night build)
5. I have ctrl-f4 instead of ctrl-w for file->close file?
6. The json file is not sorted, so it is hard to compare with another version. It would be really good if this is sorted
7. The json file contains all the keybindings. I think it would be better if it stores only the user specified bindings and leave everything else as default.
8. Can we really make a introspecting keybinder work reliably? Wouldn't it be better if we specify commands using code? VStudio has such an approach. And this would make it possible to have the sublime/vscode command windows.

I'm on gentoo linux, wx3.0.4+patch and wx-master+asan. Both wx versions behave the same sort of.
Title: Re: Keybinder v2 notes/problems
Post by: Pecan on June 28, 2019, 07:22:10 pm
I've updated my main install of the codeblocks to the latest rev and the keybinder seems to be broken for me.
Here is the list of things I've spotted as problems:

1. Memory leak from "m_pAccelEntries = new wxAcceleratorEntry[m_AccelCount];" use unique_ptr?
At the point it needs to be deleted, the whole address space is about to be destroyed. But since it seems to offend, I'll add a delete.

2. ctrl-shift-. and ctrl-shift-t doesn't work as accelerators
I'm using both shortcuts every day. Please describe your environment and how you're setting them. Further data would help me recreate the problem.
Would you attach the cbKeybinder.ini file that Keybinder tried to convert.
 
3. The new keybinder failed to parse the old config and lost all my bindings
Would you attach your old cbKeybinder.ini file so I can try and duplicate the problem. Windows or Linux? This happens on Linux for the nightly build (June 10 and prior). But I fixed this in head.

4. The old menu name is not visible on windows7 with wx-master + 4k 27inch display in the settings on windows (this is with the latest night build)
I'll try this on a VMWare Windows 7, but I don't have access to such a nice monitor. What do you mean by "wx-master" on "lastest night build" I thought the nightly builds were using 3.1 on windows. And I've I made major fixes since the latest nightly build (june 10).

5. I have ctrl-f4 instead of ctrl-w for file->close file?
Both probably work. Keybinder now preserves the global accelerators set in main.cpp . Somehow the global shortcut got set as the first accelerator. Please attach your cbKeybinder.ini file so I can try to recreate the problem.
 
6. The json file is not sorted, so it is hard to compare with another version. It would be really good if this is sorted
I agree. I'll put it on the todo list.

7. The json file contains all the keybindings. I think it would be better if it stores only the user specified bindings and leave everything else as default.
I'll put this on the todo list to see what happens.

8. Can we really make a introspecting keybinder work reliably? Wouldn't it be better if we specify commands using code? VStudio has such an approach. And this would make it possible to have the sublime/vscode command windows.
I don't know yet what any of this means. I'll do some googling.
 
I'm on gentoo linux, wx3.0.4+patch and wx-master+asan. Both wx versions behave the same sort of.
I'll try to create a VMWare gentoo. But it looks really complicated. It will take some time. I can't find an ISO image like Ubuntu or Mint that VMware Player can just load and run without all that configuration voodoo.
Title: Re: Keybinder v2 notes/problems
Post by: oBFusCATed on June 29, 2019, 10:04:44 am
1. The memory leak makes using asan harder. I can learn to ignore some leaks, but it will be best if there are as few known leaks as possible. This would make it easy for me to spot new leaks and problem.
2. ctrl-shift-. and ctrl-shift-t doesn't work on a fresh config. So I do
Code: [Select]
rm ~/.config/codeblocks/debug* -v and then start codeblocks from codeblocks. For this test I use wx-master (wxwidgets built from recent master and also I'm using asan for everything, but I doubt this last fact matters). But I see a single cbKeyBinder10.ini. Does this mean that it is common for all personalities?

3. See the attached cbKeyBinder10.ini; Linux rev 11750. wx3.0.4.
5. I've found this problem because ctrl-w didn't work.
8. This means that all commands are generated with code, so there would be explicit calls like commandManager.AddCommand(...). Current code relies on properly inspecting (introspecting) the contents of menus to find all the commands. This is less work in the beginning, but it seems unreliable to me.

It will be cool if someday we get something like this https://code.visualstudio.com/assets/docs/getstarted/tips-and-tricks/OpenCommandPalatte.gif (it can also be done with introspection the menus).
It makes it really easy to discover/use obscure features.

Title: Re: Keybinder v2 notes/problems
Post by: oBFusCATed on June 29, 2019, 04:39:57 pm
Also:
9. alt-pgup/alt-pgdown doesn't work for me. They should be set to prev/next bookmark, but they don't work. :(
Title: Re: Keybinder v2 notes/problems
Post by: Pecan on June 30, 2019, 06:44:23 pm
@ oBFusCATed

Would you try svn rev 11764 on your gentoo.
Please delete all <personality>.cbKeybinder20.conf files before testing.
(you might not have any because of a bug before rev:11741.)

I re-created the menu accelerator bug, fixed it, and tested on other Linux versions. User config'ed menu accelerators now work correctly on Mint and Ubuntu.
I will fix the memory leak after confirming that you have been successful on gentoo.

2. ctrl-shift-. and ctrl-shift-t doesn't work on a fresh config. [snip] ...
5. I've found this problem because ctrl-w didn't work.
9. alt-pgup/alt-pgdown doesn't work for me. They should be set to prev/next bookmark, but they don't work. :(
But I see a single cbKeyBinder10.ini. Does this mean that it is common for all personalities?
Accelerators are now fixed. svn rev:11764 .
I believe that cbKeyBinder10.ini appeared without a personality prefix because you might have been using a cbKeyBinder prior to rev:11741 which corrected obtaining the location of .config/.codeblocks config directory.

Thanks for finding these bugs.
Title: Re: Keybinder v2 notes/problems
Post by: oBFusCATed on July 01, 2019, 08:48:20 pm
2 and 5 are fixed it seems. Thanks. This works without deleting the config.

3. Is still broken.
Title: Re: Keybinder v2 notes/problems
Post by: Pecan on July 02, 2019, 10:51:24 pm
@ oBFusCATed

3. Is still broken.
Quote from: oBFusCATed on June 27, 2019, 10:23:34 am
3. The new keybinder failed to parse the old config and lost all my bindings

Please test rev:11766.

To test, backup your ~/.config/codeblocks/<personality>.cbKeybinder20.conf, then remove it. Else Keybinder won't process cbKeyBinder10.ini since it thinks it's already processed it once.

Also, backup and remove any <personality>.cbKeyBinder10.ini file that may not contain the keys you want from the standalone(non-personality) cbKeyBinder10.ini.

This will cause KeyBinder to use the standalone cbKeyBinder10.ini file because it cannot find a personalized one.

I forgot that there could be non-personalized cbKeyBinder10.ini files still sitting around. They don't happen anymore unless a pre-personalized version of CB is run or the file is inherited from a pre-personalized version of CB.
Title: Re: Keybinder v2 notes/problems
Post by: Pecan on July 04, 2019, 07:29:40 pm
@ oBFusCATed

4. The old menu name is not visible on windows7 with wx-master + 4k 27inch display in the settings on windows (this is with the latest night build)

wx-master fails to compile on my windows 10 or my VM windows 7.
And, I am unable to re-create the described problem with wx-3.1.1 .

Code: [Select]
if exist ..\..\lib\gcc_dll\libwxregexu.a del ..\..\lib\gcc_dll\libwxregexu.a
ar rcu ..\..\lib\gcc_dll\libwxregexu.a gcc_mswudll\wxregex_regcomp.o gcc_mswudll\wxregex_regexec.o gcc_mswudll\wxregex_regerror.o gcc_mswudll\wxregex_regfree.o
ranlib ..\..\lib\gcc_dll\libwxregexu.a
mingw32-make: *** No rule to make target '../../src/zlib/adler32.c', needed by 'gcc_mswudll\wxzlib_adler32.o'.  Stop.
Title: Re: Keybinder v2 notes/problems
Post by: sodev on July 04, 2019, 07:42:39 pm
Did you forget to update the submodules or did you fetch them at all?
Title: Re: Keybinder v2 notes/problems
Post by: Pecan on July 05, 2019, 10:18:11 pm
Did you forget to update the submodules or did you fetch them at all?

That was the problem, thanks.
Title: Re: Keybinder v2 notes/problems
Post by: Pecan on July 05, 2019, 10:21:39 pm
@ oBFusCATed

4. The old menu name is not visible on windows7 with wx-master + 4k 27inch display in the settings on windows (this is with the latest night build)

I am unable to re-create this problem with wx-master, mingw-810seh(64bit), on windows VM 7sp1 (HP laptop 17" dispaly @ res:1920x1080) .

I also cannot cause the problem on the last cbNightly ref:11712 .

Could you give me some more clues as to how to make this happen?

Title: Re: Keybinder v2 notes/problems
Post by: oBFusCATed on July 14, 2019, 06:38:27 pm
3) is now fixed thank you.

For the display issue just open the settings for the keybinder. Next time I'm on windows, I'll try to remember to provide a screenshot.
Title: Re: Keybinder v2 notes/problems
Post by: oBFusCATed on December 14, 2019, 03:11:50 pm
Another problem I've discovered is that a v2 file saved with wx28 build doesn't work on wx313 build on linux. I've tried relatively recent build. Please let me know if you need more details.
Title: Re: Keybinder v2 notes/problems
Post by: Pecan on December 17, 2019, 07:43:20 pm
Another problem I've discovered is that a v2 file saved with wx28 build doesn't work on wx313 build on linux. I've tried relatively recent build. Please let me know if you need more details.
Are there any instructions anywhere to install wx313 on linux. Mint19 only has 3.0
Title: Re: Keybinder v2 notes/problems
Post by: oBFusCATed on December 17, 2019, 08:13:35 pm
I build it manually and install in some home folder then I use --with-wx-config to point codeblocks' build to it.
Title: Re: Keybinder v2 notes/problems
Post by: Pecan on December 18, 2019, 09:08:49 pm
Another problem I've discovered is that a v2 file saved with wx28 build doesn't work on wx313 build on linux. I've tried relatively recent build. Please let me know if you need more details.

I cannot duplicate this error on Windows; nor on Linux Mint19 using wxWidgets 3.1.3 .

I suspect your .config/codeblocks directory already contains a [personality].cbKeybinder20.conf file.
In which case neither [personality].cbKeybinder10.ini nor ancient cbKeybinder10.ini will be scanned for key definitions.
 
Title: Re: Keybinder v2 notes/problems
Post by: oBFusCATed on December 19, 2019, 09:43:06 am
Yes, I'm migrating from v2 to v2, but for some reason the file generated by v2.wx28 doesn't work correctly with v2.wx31.
I've custom keybindings - ctrl-shift-f for view -> focus thread search is an example.
Title: Re: Keybinder v2 notes/problems
Post by: Pecan on December 19, 2019, 07:06:43 pm
Yes, I'm migrating from v2 to v2, but for some reason the file generated by v2.wx28 doesn't work correctly with v2.wx31.
I've custom keybindings - ctrl-shift-f for view -> focus thread search is an example.

I cannot test this since ThreadSearch will not run with head.
I get asserts when CB loads ThreadSearch.

Why would anybody be building head with wx28. I thought we were dropping wx28.

Do you mean that you are attempting to use  (copy)[profile].cbKeyBinder20.conf build by wx28 on CodeBlocks built by wx31?
Title: Re: Keybinder v2 notes/problems
Post by: oBFusCATed on December 19, 2019, 08:33:56 pm
I have a centos7 build which is wx28. This is my regular build I use every day. It is not the latest version, but it is pretty new.
I want to migrate to wx3.x and I'm experimenting with a centos7 build which is using wx3.1.3.
This means that I was using wx28 for some time, then I've installed the new build which is now wx3.1.3 and I've discovered this breakage.
Title: Re: Keybinder v2 notes/problems
Post by: Pecan on December 21, 2019, 10:04:17 pm
I have a centos7 build which is wx28. This is my regular build I use every day. It is not the latest version, but it is pretty new.
I want to migrate to wx3.x and I'm experimenting with a centos7 build which is using wx3.1.3.
This means that I was using wx28 for some time, then I've installed the new build which is now wx3.1.3 and I've discovered this breakage.

@oBFusCATed

I'm having trouble creating this situation. I must be mis-understanding.

Could you give me the exact steps to cause this problem, starting with:
Title: Re: Keybinder v2 notes/problems
Post by: oBFusCATed on December 22, 2019, 12:51:19 am
1. no idea
2. 11925 probably
3. not possible before next year :)
Title: Re: Keybinder v2 notes/problems
Post by: oBFusCATed on February 23, 2020, 02:08:13 pm
Today I've had the ctrl-w stop working and tried to rectify the situation, but then I've got this message "KeyBinding file corrupted. Please delete". What should I delete?

See the attached config file.
Title: Re: Keybinder v2 notes/problems
Post by: Pecan on February 25, 2020, 09:05:21 pm
Today I've had the ctrl-w stop working and tried to rectify the situation, but then I've got this message "KeyBinding file corrupted. Please delete". What should I delete?

See the attached config file.

You must be using an old version of keybinder. That event was fixed a few revision ago.
That message does not exist anymore.
Title: Re: Keybinder v2 notes/problems
Post by: oBFusCATed on February 26, 2020, 08:24:13 pm
I don't remember, there is a chance I might have used a build from the release-20.xx branch.
Could you do some test with such a build and tell me if I've picked all required commits?
Title: Re: Keybinder v2 notes/problems
Post by: Pecan on February 27, 2020, 05:30:06 pm
Today I've had the ctrl-w stop working and tried to rectify the situation, but then I've got this message "KeyBinding file corrupted. Please delete". What should I delete?

See the attached config file.

You must be using an old version of keybinder. That event was fixed a few revision ago.
That message does not exist anymore.

I've been able to re-create this problem. Am now working on it.
It's caused by using a <personality>.cbKeyBinder20.conf file from one build on a different build. The menu id's don't match.
Title: Re: Keybinder v2 notes/problems
Post by: Pecan on March 02, 2020, 07:51:23 pm
Today I've had the ctrl-w stop working and tried to rectify the situation, but then I've got this message "KeyBinding file corrupted. Please delete". What should I delete?

See the attached config file.

You must be using an old version of keybinder. That event was fixed a few revision ago.
That message does not exist anymore.

I've been able to re-create this problem. Am now working on it.
It's caused by using a <personality>.cbKeyBinder20.conf file from one build on a different build. The menu id's don't match.

Fixed SVN 11974
Title: Re: Keybinder v2 notes/problems
Post by: oBFusCATed on March 07, 2020, 08:29:32 pm
Is there any reason you're storing random numerical ids?
Isn't it possible to use the menu item label (before translation) as an identifier instead?
Title: Re: Keybinder v2 notes/problems
Post by: Pecan on March 09, 2020, 06:09:44 pm
Is there any reason you're storing random numerical ids?
Isn't it possible to use the menu item label (before translation) as an identifier instead?

Numerical id's are used by tradition from the original KeyBinder code suggested to me in 2005. And they're also used by the code from CodeLite.

I'll look into the possiblity of using only the Menu tree paths instead.

But that, I think, will take a lot of time. Duplicate menu labels and translated menu labels will cause many problems to solve.

To use menu labels will require a rewrite.
Title: Re: Keybinder v2 notes/problems
Post by: oBFusCATed on March 09, 2020, 11:25:32 pm
For the record, today I've upgraded to this version and I've seen zero problems. I'll wait a day or two and the last un-picked keybinder commits are going to the release branch. 8)
Title: Re: Keybinder v2 notes/problems
Post by: oBFusCATed on March 22, 2020, 11:38:29 am
I've lost all my shortcuts again. I'm on 11979.
See the config file attached.

Does the plugin logs when it fails to set a shortcut? I don't see any error/warning messages.
Title: Re: Keybinder v2 notes/problems
Post by: Pecan on March 23, 2020, 06:06:45 am
I've lost all my shortcuts again. I'm on 11979.
See the config file attached.

Does the plugin logs when it fails to set a shortcut? I don't see any error/warning messages.


rev 11979 is before the keybinder fixes. Update your keybinder plugin.
Title: Re: Keybinder v2 notes/problems
Post by: oBFusCATed on March 23, 2020, 09:10:38 am
If I see correctly
Code: [Select]
    * Keybinder 2.0.11 2020/03/02 fix missing/conflicting shortcuts when using older .conf on newer build
      - Check for mismatched menu id's to global accelerators id's
        Cf.,This will allow a global to override an old menu item.This happends when a new build does not match the current .conf file
        The non-matching .conf menu item has an incorrect id anyway.
      - When a .conf menu id matches a default( current structure) menu id, also make sure the menu path (parentMenu) also matches.
        It can mismatch when using a keybinder .conf configured from a previously built version of CodeBlocks on a newer build.
      - Set the global accelerators table before calling Initilaize::Update() else globals are missed on the first invocation of KeyBinder/Configure.
   
   
    git-svn-id: https://svn.code.sf.net/p/codeblocks/code/[email protected] 2a5c6006-c6dd-42ca-98ab-0921f2732cef

is the last commit for the keybinder and its revision is 11974... I'm talking about commits in trunk/master.
Title: Re: Keybinder v2 notes/problems
Post by: Pecan on March 24, 2020, 08:26:36 pm
I've lost all my shortcuts again. I'm on 11979.
See the config file attached.

Does the plugin logs when it fails to set a shortcut? I don't see any error/warning messages.

Fixed At revision: 11993
KeyBinder 2.0.12 2020/03/23 Match .conf to menu structure (by menu titles) to replace old menu ids with newer.
Title: Re: Keybinder v2 notes/problems
Post by: oBFusCATed on March 24, 2020, 09:31:16 pm
Should I pick this for 20.xx?
Title: Re: Keybinder v2 notes/problems
Post by: Pecan on March 24, 2020, 09:54:00 pm
Should I pick this for 20.xx?

Yes, please do. It compares by menu title as you had suggested.
It can now find the new menu id when the menu structure changes.
Thus preserving user defined accelerators even when the menu structure is radically changed by a new build.

 
Title: Re: Keybinder v2 notes/problems
Post by: oBFusCATed on March 25, 2020, 01:37:16 am
What happens if there are duplicate menu items? How does it handle it?

I'll test it myself a day or two and then it will go to 20.xx...
Title: Re: Keybinder v2 notes/problems
Post by: Pecan on March 25, 2020, 02:17:59 am
What happens if there are duplicate menu items? How does it handle it?

I'll test it myself a day or two and then it will go to 20.xx...

There wont be duplicates. Keybinder compares with the full menu path not just the item title.
Eg., "&Build::Run" can't match "&MyPlugin::Run" (if there was such an item title);

Thanks for testing.
Title: Re: Keybinder v2 notes/problems
Post by: oBFusCATed on March 26, 2020, 08:44:45 pm
BTW: Is this a regression relative to 17.12. I've never been able to preserve my keybinder settings for years. If this is not a regression, I'd rather prefer not to delay the release even further...
Title: Re: Keybinder v2 notes/problems
Post by: Pecan on March 27, 2020, 05:47:34 am
BTW: Is this a regression relative to 17.12. I've never been able to preserve my keybinder settings for years. If this is not a regression, I'd rather prefer not to delay the release even further...

Sorry, I don't know what you mean by "Is this a regression..."

But this new KeyBinder version is the first time KeyBinder has attempted to save all the users bindings between re-builds that altered the menu tree ids.
Title: Re: Keybinder v2 notes/problems
Post by: oBFusCATed on March 27, 2020, 09:59:29 am
If the problem existed in 17.12 then not fixing it in 20.xx is not a regression. If problem wasn't there and it exists now then it is a regression. The idea of this is if the software got worse and not better.
Title: Re: Keybinder v2 notes/problems
Post by: Pecan on March 27, 2020, 06:39:05 pm
If the problem existed in 17.12 then not fixing it in 20.xx is not a regression. If problem wasn't there and it exists now then it is a regression. The idea of this is if the software got worse and not better.

In my view, the software has gotten better. It saves all the users' defined key bindings, even when CB gets re-built and/or wxWidgets changes the way it assigns menu ids.

Version 17.12 bailed out when there were more than three bindings that had no matching menu ids.
Title: Re: Keybinder v2 notes/problems
Post by: oBFusCATed on March 27, 2020, 07:19:46 pm
I don't deny this. I don't know if it is worth it to do rebuilds.
Title: Re: Keybinder v2 notes/problems
Post by: Pecan on March 27, 2020, 07:27:26 pm
I don't deny this. I don't know if it is worth it to do rebuilds.

Since it was you that was annoyed about losing your bindings, it might suggest that others are as interested in saving them as you are.
I know I'd appreciate it, I'm tired of losing bindings everytime I have to do a major build.
But I understand that we all have limited contribution time.
Title: Re: Keybinder v2 notes/problems
Post by: oBFusCATed on March 30, 2020, 12:50:25 am
Hm, now I've lost the keybindings for prev/next bookmark (alt-pgup/pgdown).
Any idea why this might have happened?
Currently using rev 12002. No idea how this has happened. I don't remember removing them manually. :(

Looking in the config the keys for these menu entries are empty.
Would it be possible to store only bindings different from the default? Or somehow manually set by the user?