Author Topic: patch to open files with double-click in explorer (and from cmd-line)  (Read 7882 times)

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7252
Here's a patch that (re?)enables C::B to open (source-, header and resource-)files by double-clicking on it in explorer or to open them via command-line from console.
I tested it on my laptop with Debian Sid-/Experimental-mix and on my virtual W2K-box.

Code
--- codeblocks-1.0svn.orig/src/src/app.cpp      2007-12-07 20:03:08.000000000 +0100
+++ codeblocks-1.0svn.work/src/src/app.cpp     2007-12-11 00:21:48.000000000 +0100
@@ -900,6 +900,10 @@
                             m_HasProject = true;
                             s_DelayedFilesToOpen.Add(parser.GetParam(param));
                         }
+                        else if (ft == ftSource || ft == ftHeader || ft == ftResource)
+                        {
+                            s_DelayedFilesToOpen.Add(parser.GetParam(param));
+                        }
                         else if (ft == ftCodeBlocksWorkspace)
                         {
                             // only one workspace can be opened

Please have a look to my patch for "debuggergdb.cpp" also: http://forums.codeblocks.org/index.php/topic,7402.msg56437.html#msg56437.
The problem here is that the crash just happens in the rare case, someone has a Project with RemoteDebugging-targets, closes this one and then creates a new one, that of course has no such targets.
In this case the new project is saved automatically, but the RemoteDebuggingMaps size is not zero, so C::B tries to save it too. But when it runs GetTitle() it crashs.
So clearing the Map in OnProjectClose() is the easiest way to avoid this, and it should not break anything other.

Sorry to have mixed two issues in the post, but I don't want to file a bug-report if it's not really necessary.
« Last Edit: December 20, 2007, 09:12:41 am by jens »

Offline gd_on

  • Lives here!
  • ****
  • Posts: 824
Re: patch to open files with double-click in explorer (and from cmd-line)
« Reply #1 on: December 12, 2007, 10:11:17 pm »
I tried your patch on svn 4728 compiled with gcc 4.2.2 dw2, on Win XP. Sorry, nothing is changed for me. A double click on a .c, .h, .rc file, or a .cbp file, opens C::B, but it stay on the start page. File or project is open only if an artificial event is created (reducing the window in the tray for example,....) or other workaround solutions, previously indicated(disabling code completion, creating a dummy plugin,...

good luck.

gd_on
Windows 11 64 bits (24H2), svn C::B (last version or almost!), wxWidgets 3.2.8 (tests with 3.3), Msys2 Compilers 15.1.0, 64 bits (seh, posix : gcc, g++ and gfortran in C:\msys64\mingw64) or 32 bits (dwarf2, posix  in C:\msys64\mingw32).

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7252
Re: patch to open files with double-click in explorer (and from cmd-line)
« Reply #2 on: December 13, 2007, 12:15:09 pm »
I just tried it with a fresh svn4728, wxWidgets 2.8.7 and gcc 4.2.1-dw2 on an uptodate 32-bit WinXP system on a Core2Duo-Laptop.
Works as expected with (even multiple) files from commandline and by double-clicking on a file in explorer.
Tested with .cbp, .workspace, .cpp, .h and .rc .

After closing the startup-tips MessageBox the file(s) get loaded.

Offline gd_on

  • Lives here!
  • ****
  • Posts: 824
Re: patch to open files with double-click in explorer (and from cmd-line)
« Reply #3 on: December 13, 2007, 02:34:57 pm »
Sorry for my mistake, it's effectively gcc version 4.2.1 dw2.
I tested also on Win2K, uptodated also, same wxWidgets 2.8.7, fresh C::B install, but the behaviour is not the same : .c, .cbp, ... opens correctly. I have just a problem  when I quit C::B if I close it quickly without doing anything (error message that a component or a file is missing, but no message if code completion is disabled :(, but as it is useful, I ignore this message :lol:). If I swich between windows, compile,... it's OK when quiting. A strange thing is, if I redisplay the window form which my .cbp file was started, just after starting C::B, this window looks freezed one or 2 minutes or simply does not open when I click on it in the bottom task bar... But after a while, if this window can be opened, if I close C::B, everything is OK, no error message.
But on my XP machine, it's always as I described before... My PC is 4 years old, a 3 Ghz processor, but single core, "just" hyperthreading technology... Note that my Win2K machine is still older and slower (2.4 Ghz) !!! Could it be a problem with processor speed, synchronization of events, ... ?

gd_on
Windows 11 64 bits (24H2), svn C::B (last version or almost!), wxWidgets 3.2.8 (tests with 3.3), Msys2 Compilers 15.1.0, 64 bits (seh, posix : gcc, g++ and gfortran in C:\msys64\mingw64) or 32 bits (dwarf2, posix  in C:\msys64\mingw32).

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7252
Re: patch to open files with double-click in explorer (and from cmd-line)
« Reply #4 on: December 13, 2007, 04:17:34 pm »
There seem to be problems witth DDE (on Windows) : http://forums.codeblocks.org/index.php/topic,7442.msg56487.html#msg56487.
This might cause your problems on the XP machine.

Afaik there are more posts about freezing C::B for some seconds up to some minutes when trying to open files with double-clicking, but I don't find them at the moment.

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9723
Re: patch to open files with double-click in explorer (and from cmd-line)
« Reply #5 on: January 03, 2008, 01:37:54 pm »
Here's a patch that (re?)enables C::B to open (source-, header and resource-)files by double-clicking on it in explorer or to open them via command-line from console.
...applied in SVN. Thanks! :-)
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ