Author Topic: is it possible to use many CB instances ?  (Read 4471 times)

Offline Elena

  • Multiple posting newcomer
  • *
  • Posts: 38
is it possible to use many CB instances ?
« on: March 15, 2021, 12:10:42 am »
I would like to have several projects each one opened in a separate instance of CB.
To do that I thought that I had to disable both general options
Allow only one running instance...
And
Use an already running instance
Unfortunately even having both options disabled, if I open a .cbp it gets opened inside an already running instance which causes a mess and shouldn't even be allowed imho.
What to do? Thx

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13438
    • Travis build status
Re: is it possible to use many CB instances ?
« Reply #1 on: March 15, 2021, 01:35:14 am »
Open a second instance and then file -> open -> your project
Modify your file associations command to use the --no-ipc option (use --help or /help to check which is the correct spelling for your OS).
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline Elena

  • Multiple posting newcomer
  • *
  • Posts: 38
Re: is it possible to use many CB instances ?
« Reply #2 on: March 15, 2021, 02:04:34 am »
Sorry I forgot to specify that I am on Windows. I am opening my projects by double click on them, not by first launching CB and then opening the project. And when I double click on a project file in Windows and CB is already running, the new project is opened in the already running instance which is what I want to avoid...

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13438
    • Travis build status
Re: is it possible to use many CB instances ?
« Reply #3 on: March 15, 2021, 02:42:02 pm »
Modify your file associations command to use the --no-ipc option (use --help or /help to check which is the correct spelling for your OS).

(I don't know how to do that...)
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 3018
Re: is it possible to use many CB instances ?
« Reply #4 on: March 15, 2021, 09:55:45 pm »
Settings->Environment->General settings->Untick Allow only one running instance
Settings->Environment->General settings-> untick use an already running instance

Offline Elena

  • Multiple posting newcomer
  • *
  • Posts: 38
Re: is it possible to use many CB instances ?
« Reply #5 on: March 15, 2021, 10:07:04 pm »
You really haven't read my post sigh... I said I have disabled them but they do not work

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 3018
Re: is it possible to use many CB instances ?
« Reply #6 on: March 15, 2021, 10:16:16 pm »
Quote
You really haven't read my post sigh... I said I have disabled them but they do not work
Sry, but 90% the time this is the answer... And we answer 90% the same questions, so i get some automating going in my head... read the header, give standard answer...
Have you restarted codeblocks? This has never not worked for me on windows. On linux there was a bug, but i think we have fixed this...

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 3018
Re: is it possible to use many CB instances ?
« Reply #7 on: March 15, 2021, 10:55:25 pm »
Also if a restart does not work:
Are the settings saved?
Are other settings saved?

Offline Elena

  • Multiple posting newcomer
  • *
  • Posts: 38
Re: is it possible to use many CB instances ?
« Reply #8 on: March 15, 2021, 11:27:10 pm »
 ;D ;D
Yes I restarted. I even rebooted. And yep general settings are saved nicely...
By searching I found an old post of 2016 iirc where another user complained of the same issue and it turned out a bug (I reported it again), strange that it was never fixed in the meanwhile... :'(

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 3018
Re: is it possible to use many CB instances ?
« Reply #9 on: March 16, 2021, 12:50:51 am »
Can you point (link?) to the complain?
The problem is, none of the devs (or other users) has reproduced this, so it has to be something very special with your machine....
Now is the big question how do we reproduce this problem on a machine of the devs...
Can you give us windows version (7,8...) Bitnes (32bit, 64 bit)
What exact version of codeblocks are you using? Where did you get it?

Can you open two separate codeblocks instances, by clicking on the codeblocks icon, or on windows 7/8/10 right click on the codeblocks symbol in the taskbar ->  codeblocks?

Offline Elena

  • Multiple posting newcomer
  • *
  • Posts: 38
Re: is it possible to use many CB instances ?
« Reply #10 on: March 16, 2021, 01:29:22 am »
So... this was the thread I mentioned. It was marked as SOLVED but to me it doesn't quite seems so...
http://forums.codeblocks.org/index.php?topic=21350.0

I am using CB  20.03 downloaded from here
https://www.codeblocks.org/downloads/binaries/

I am on windows 7 x64 ultimate but I tried and under windows 10 x64 the behaviour is the same.
If I launch another instance by double clicking codeblocks.exe or by right click in the task bar it actually opens another instance, but not if I double click on a .cbp

Offline Miguel Gimenez

  • Lives here!
  • ****
  • Posts: 823
Re: is it possible to use many CB instances ?
« Reply #11 on: March 16, 2021, 10:02:49 am »
The OP wants that double clicking on a .CBP file
Runs a new instance of the program. Currently you must
Open a new C::B and then
Load the project in the new instance using the menu.
Looks like a feature request, not really a bug.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13438
    • Travis build status
Re: is it possible to use many CB instances ?
« Reply #12 on: March 16, 2021, 10:16:59 am »
It is clearly a bug. There are already options to enable this behaviour!
And there are previous reports for brokenness of this feature.
Someone with windows should investigate what is going on.

@Elena: Can you show us the contents of your registry for "HKEY_CURRENT_USER\Software\Classes\CodeBlocks.exe"?
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline Elena

  • Multiple posting newcomer
  • *
  • Posts: 38
Re: is it possible to use many CB instances ?
« Reply #13 on: March 16, 2021, 01:03:01 pm »
Thanks Obfuscated, yeah to me it seems a bug without doubts because those two options (other than being apparently redundant imho) do not work. Also most times it is much more practical to open the .cbp rather than launching an empty CB locate the project and load it!
Anyway there is not any Codeblocks.exe key in my registry, there are many (.asm, .c,.cbp,...) but not the .exe... you really mean classes/codeblocks.exe ?

Offline Miguel Gimenez

  • Lives here!
  • ****
  • Posts: 823
Re: is it possible to use many CB instances ?
« Reply #14 on: March 16, 2021, 01:53:36 pm »
This is the content of my "HKEY_CURRENT_USER\Software\Classes\CodeBlocks.cbp" entry:

Code
Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\SOFTWARE\Classes\CodeBlocks.cbp]
@="project file"

[HKEY_CURRENT_USER\SOFTWARE\Classes\CodeBlocks.cbp\DefaultIcon]
@="C:\\Codeblocks\\src\\output31\\codeblocks.exe,1"

[HKEY_CURRENT_USER\SOFTWARE\Classes\CodeBlocks.cbp\shell]

[HKEY_CURRENT_USER\SOFTWARE\Classes\CodeBlocks.cbp\shell\Build]

[HKEY_CURRENT_USER\SOFTWARE\Classes\CodeBlocks.cbp\shell\Build\command]
@="\"C:\\Codeblocks\\src\\output31\\codeblocks.exe\" -na -nd -ns --batch-build-notify --build \"%1\""

[HKEY_CURRENT_USER\SOFTWARE\Classes\CodeBlocks.cbp\shell\open]

[HKEY_CURRENT_USER\SOFTWARE\Classes\CodeBlocks.cbp\shell\open\command]
@="\"C:\\Codeblocks\\src\\output31\\codeblocks.exe\" \"%1\""

[HKEY_CURRENT_USER\SOFTWARE\Classes\CodeBlocks.cbp\shell\open\ddeexec]
@="[Open(\"%1\")]"

[HKEY_CURRENT_USER\SOFTWARE\Classes\CodeBlocks.cbp\shell\open\ddeexec\application]
@="CODEBLOCKS"

[HKEY_CURRENT_USER\SOFTWARE\Classes\CodeBlocks.cbp\shell\open\ddeexec\ifexec]
@="[IfExec_Open(\"%1\")]"

[HKEY_CURRENT_USER\SOFTWARE\Classes\CodeBlocks.cbp\shell\open\ddeexec\topic]
@="CodeBlocksDDEServer"

[HKEY_CURRENT_USER\SOFTWARE\Classes\CodeBlocks.cbp\shell\Rebuild (clean)]

[HKEY_CURRENT_USER\SOFTWARE\Classes\CodeBlocks.cbp\shell\Rebuild (clean)\command]
@="\"C:\\Codeblocks\\src\\output31\\codeblocks.exe\" -na -nd -ns --batch-build-notify --rebuild \"%1\""

If you remove the ddeexec folder all work as intended. IMHO this entry is redundant with the code, and in some tests it makes C::B freeze.

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 3018
Re: is it possible to use many CB instances ?
« Reply #15 on: March 16, 2021, 05:27:46 pm »
Yep, this is a problem with the DDE server in codeblocks.
I never hit this error, because i do not install codeblocks, or let it associate the file extensions and so i have not this registy entries
The easiest solution is to remove the ddeexec  from the registry...

Hopefully i find some time to look into it...

Offline Miguel Gimenez

  • Lives here!
  • ****
  • Posts: 823
Re: is it possible to use many CB instances ?
« Reply #16 on: March 16, 2021, 05:32:53 pm »
I have just posted a patch in ticket 1082, https://sourceforge.net/p/codeblocks/tickets/1082/. This patch does not create ddeexec entries (and remove them if they exist) when setting file associations.

Offline Elena

  • Multiple posting newcomer
  • *
  • Posts: 38
Re: is it possible to use many CB instances ?
« Reply #17 on: March 16, 2021, 05:50:21 pm »
@Miguel
If I delete the ddexec folder I simply have CB not loading a project the next time I double click on a .cbp, but it opens a requester saying:
Code::Blocks is not the default application for C/C++ source files.......
Why it does not work for me ?? As I said this at least happens on win7 ultimate x64, I can't test on another win right now

Offline Miguel Gimenez

  • Lives here!
  • ****
  • Posts: 823
Re: is it possible to use many CB instances ?
« Reply #18 on: March 16, 2021, 06:03:53 pm »
Quote
win7 ultimate x64
is the system I am using right now. The double click is handled by the CodeBlocks.cbp/shell/open/command folder. You must have something like this (the path to the executable will be different)

Code
Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Software\Classes\CodeBlocks.cbp]
@="project file"

[HKEY_CURRENT_USER\Software\Classes\CodeBlocks.cbp\DefaultIcon]
@="C:\\Codeblocks314\\src\\output31\\codeblocks.exe,1"

[HKEY_CURRENT_USER\Software\Classes\CodeBlocks.cbp\shell]

[HKEY_CURRENT_USER\Software\Classes\CodeBlocks.cbp\shell\Build]

[HKEY_CURRENT_USER\Software\Classes\CodeBlocks.cbp\shell\Build\command]
@="\"C:\\Codeblocks314\\src\\output31\\codeblocks.exe\" -na -nd -ns --batch-build-notify --build \"%1\""

[HKEY_CURRENT_USER\Software\Classes\CodeBlocks.cbp\shell\open]

[HKEY_CURRENT_USER\Software\Classes\CodeBlocks.cbp\shell\open\command]
@="\"C:\\Codeblocks314\\src\\output31\\codeblocks.exe\" \"%1\""

[HKEY_CURRENT_USER\Software\Classes\CodeBlocks.cbp\shell\Rebuild (clean)]

[HKEY_CURRENT_USER\Software\Classes\CodeBlocks.cbp\shell\Rebuild (clean)\command]
@="\"C:\\Codeblocks314\\src\\output31\\codeblocks.exe\" -na -nd -ns --batch-build-notify --rebuild \"%1\""

Offline Elena

  • Multiple posting newcomer
  • *
  • Posts: 38
Re: is it possible to use many CB instances ?
« Reply #19 on: March 16, 2021, 07:38:58 pm »
Looks pretty identical to mine.. except that I cannot delete ddexec otherwise cb opens the requester I described in my previous message,  and I have to confirm the associations otherwise I would lose them, and it rebuilds the ddexec

Offline Elena

  • Multiple posting newcomer
  • *
  • Posts: 38
Re: is it possible to use many CB instances ?
« Reply #20 on: March 16, 2021, 07:48:37 pm »
However if I launch it from a shell with a project name it opens a new instance effectively... but never if I double click on a .cbp!

Offline Miguel Gimenez

  • Lives here!
  • ****
  • Posts: 823
Re: is it possible to use many CB instances ?
« Reply #21 on: March 16, 2021, 07:49:09 pm »
You can try clicking right button on a .CBP and associate it with CodeBlocks.exe, other than that I can't help.

Here you have how ddeexec works: https://docs.microsoft.com/en-us/windows/win32/shell/how-to-associate-verbs-with-dde-commands

Offline Elena

  • Multiple posting newcomer
  • *
  • Posts: 38
Re: is it possible to use many CB instances ?
« Reply #22 on: March 16, 2021, 08:03:02 pm »
That requester is for nothing btw... even if you select to leave things as they are you have not lost the files association. It is clearly a bug there..you delete the ddexec and it goes nuts..the same requester opens at startup even if I change the the open/command key!! It is harmless but should not definitely open. Anyway I even tried to change the open/command key to [cb path] --multiple-instance "%1" but to no avail, it keeps opening .cbp projects in an alrrady running instance. And there things are buggy aswell, since in the title bar it remains the previous project name even if I click on the second project, and when you select Build you don't even know WHICH project it is building... with two projects opened in a single instance also I got a crash yesterday! If I wete the coder I'd have fixed everything already sigh2

Offline Elena

  • Multiple posting newcomer
  • *
  • Posts: 38
Re: is it possible to use many CB instances ?
« Reply #23 on: March 16, 2021, 08:22:27 pm »
In the end I managed to do it! Phew... I had to repeat the operation of deleting the ddexec few times, ignore the requester, reboot, and now apparently it opens all my .cbp files in separate instances 😃 It simply did not work at the first attempts....

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 3018
Re: is it possible to use many CB instances ?
« Reply #24 on: March 16, 2021, 10:53:22 pm »
You can disable the file association check in the options: Settings->Environment->Check&Set file associations (Windows only)
Anyway this is a bug and we will try to fix it

Offline Elena

  • Multiple posting newcomer
  • *
  • Posts: 38
Re: is it possible to use many CB instances ?
« Reply #25 on: March 16, 2021, 10:56:16 pm »
Well yes even because if I delete that key it has nothing to do with the files associations, clearly C::B makes some wrong assumption there. Thanks for your support

Offline Miguel Gimenez

  • Lives here!
  • ****
  • Posts: 823
Re: is it possible to use many CB instances ?
« Reply #26 on: March 17, 2021, 09:38:57 am »
My patch also removes checking of ddeexec presence, so C::B will not complain on start.

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9615
Re: is it possible to use many CB instances ?
« Reply #27 on: March 20, 2021, 07:08:12 am »
My patch also removes checking of ddeexec presence, so C::B will not complain on start.
Sorry, I didn't see this thread in advance so I answered to the ticket. I'll add my answer here, too for the record:

One note: From what I see this removes the DDE feature completely. DDE could also used on Windows to automate build processes, if properly used. So while this patch indeed fixes the bug mentioned but also removes the ability to script-control C::B from outside in case you really use just one instance (which is an option).

So this solution is not perfect... just my 2 cents here.

A better solution is to check if you are in single instance mode and then allow DDE commands. Additionally besides opening a file we could literally add any operation via DDE to kind of "remote-control" C::B. I do so for other applications at my work, also using the wx-DDE mechanisms with nice benefits.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: http://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: http://wiki.codeblocks.org/index.php?title=FAQ

Offline Miguel Gimenez

  • Lives here!
  • ****
  • Posts: 823
Re: is it possible to use many CB instances ?
« Reply #28 on: March 20, 2021, 11:16:42 am »
No, the patch only removes automatic DDE calls when double clicking on an associated file. DDE is still there.