Developer forums (C::B DEVELOPMENT STRICTLY!) > CodeCompletion redesign

Patch for wizard's default compiler error

(1/1)

Loaden:
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)
--- End code ---
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>

--- End code ---
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;
    }
 
--- End code ---


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);

--- End code ---

[attachment deleted by admin]

killerbot:
why do you do twice a 'CompilerFactory::SetDefaultCompiler' ?

MortenMacFly:

--- Quote from: killerbot on March 23, 2010, 07:44:21 am ---why do you do twice a 'CompilerFactory::SetDefaultCompiler' ?

--- End quote ---
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.

killerbot:
yes, I see now :-)

Navigation

[0] Message Index

Go to full version