Code::Blocks Forums

Developer forums (C::B DEVELOPMENT STRICTLY!) => Development => CodeCompletion redesign => Topic started by: Loaden on March 23, 2010, 05:21:38 AM

Title: Patch for wizard's default compiler error
Post by: Loaden 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:
void NativeParser::AddCompilerDirs(cbProject* project)
In the project directory will create a project file, which reads:
<?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:
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:
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]
Title: Re: Patch for wizard's default compiler error
Post by: killerbot on March 23, 2010, 07:44:21 AM
why do you do twice a 'CompilerFactory::SetDefaultCompiler' ?
Title: Re: Patch for wizard's default compiler error
Post by: MortenMacFly on March 23, 2010, 09:32:25 AM
Quote from: killerbot on March 23, 2010, 07:44:21 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.
Title: Re: Patch for wizard's default compiler error
Post by: killerbot on March 23, 2010, 09:42:11 AM
yes, I see now :-)