Author Topic: Patch for wizard's default compiler error  (Read 9330 times)

Offline Loaden

  • Lives here!
  • ****
  • Posts: 1014
Patch for wizard's default compiler error
« on: March 23, 2010, 05:21:38 am »
I have TWO compilers for CB, the default compiler is MinGW(gcc), and another is MSVC.

Now, When I create new MSVC8 projects, and debug CB, when step to this code:
Code
void NativeParser::AddCompilerDirs(cbProject* project)
In the project directory will create a project file, which reads:
Code
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<CodeBlocks_project_file>
 <FileVersion major="1" minor="6" />
 <Project>

  <Option title="" />
  <Option pch_mode="2" />

  <Option compiler="gcc" />
  <Build />
  <Extensions>
   <code_completion />
   <debugger />
  </Extensions>
 </Project>
</CodeBlocks_project_file>
We can see this line:  <Option compiler="gcc" />
It's must be msvc8, but NOT gcc!

So, I make a patch to fix this BUG.
Like this:
Code
CompileTargetBase* Wiz::RunProjectWizard(wxString* pFilename)
{
...
    // now create the project
+    wxString defCompilerID = CompilerFactory::GetDefaultCompilerID();
+    CompilerFactory::SetDefaultCompiler(GetCompilerID());
    theproject = Manager::Get()->GetProjectManager()->NewProject(prjname);
+    CompilerFactory::SetDefaultCompiler(defCompilerID);
    if (!theproject)
    {
        cbMessageBox(_("Couldn't create the new project:\n") + prjdir, _("Error"), wxICON_ERROR);
        Clear();
        return 0;
    }
 


This patch only add three statements.
Now, it's work well.

Patch in here:
Code
Index: src/plugins/scriptedwizard/wiz.cpp
===================================================================
--- src/plugins/scriptedwizard/wiz.cpp (revision 6195)
+++ src/plugins/scriptedwizard/wiz.cpp (working copy)
@@ -346,7 +346,10 @@
     }
 
     // now create the project
+    wxString defCompilerID = CompilerFactory::GetDefaultCompilerID();
+    CompilerFactory::SetDefaultCompiler(GetCompilerID());
     theproject = Manager::Get()->GetProjectManager()->NewProject(prjname);
+    CompilerFactory::SetDefaultCompiler(defCompilerID);
     if (!theproject)
     {
         cbMessageBox(_("Couldn't create the new project:\n") + prjdir, _("Error"), wxICON_ERROR);

[attachment deleted by admin]
« Last Edit: March 23, 2010, 05:27:29 am by Loaden »

Offline killerbot

  • Administrator
  • Lives here!
  • *****
  • Posts: 5491
Re: Patch for wizard's default compiler error
« Reply #1 on: March 23, 2010, 07:44:21 am »
why do you do twice a 'CompilerFactory::SetDefaultCompiler' ?

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: Patch for wizard's default compiler error
« Reply #2 on: March 23, 2010, 09:32:25 am »
why do you do twice a 'CompilerFactory::SetDefaultCompiler' ?
One time for setting the right compiler and one time for setting the old default compiler. This is correct. But I must admit that it looked weired to me in the first place, too.
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

Offline killerbot

  • Administrator
  • Lives here!
  • *****
  • Posts: 5491
Re: Patch for wizard's default compiler error
« Reply #3 on: March 23, 2010, 09:42:11 am »
yes, I see now :-)