Author Topic: [FIXED] Patch for what I think is an coding bug in compileroptionsdlg.cpp  (Read 3983 times)

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7600
    • My Best Post
FYI:

While trying to patch Code::Blocks for wxWidgets 2.9x I found an place where an string is compared to an int.

Tim S

PS: I have been up for over an day; so, take that into consideration.

excerpt from compilerfactory.h
Code
static const wxString& GetDefaultCompilerID();

excerpt from compileroptionsdlg.cpp
Code
        int idx   = XRCCTRL(*this, "cmbCompiler", wxChoice)->GetSelection();
        int count = XRCCTRL(*this, "cmbCompiler", wxChoice)->GetCount(); // compilers count
        Compiler* compiler = CompilerFactory::GetCompiler(idx);

        XRCCTRL(*this, "btnSetDefaultCompiler", wxButton)->Enable(CompilerFactory::GetDefaultCompilerID() != idx);

Patch that I think is needed
Code
Index: src/plugins/compilergcc/compileroptionsdlg.cpp
===================================================================
--- src/plugins/compilergcc/compileroptionsdlg.cpp (revision 5204)
+++ src/plugins/compilergcc/compileroptionsdlg.cpp (working copy)
@@ -2124,7 +2124,7 @@
         int count = XRCCTRL(*this, "cmbCompiler", wxChoice)->GetCount(); // compilers count
         Compiler* compiler = CompilerFactory::GetCompiler(idx);
 
-        XRCCTRL(*this, "btnSetDefaultCompiler", wxButton)->Enable(CompilerFactory::GetDefaultCompilerID() != idx);
+        XRCCTRL(*this, "btnSetDefaultCompiler", wxButton)->Enable(CompilerFactory::GetCompilerIndex(CompilerFactory::GetDefaultCompiler()) != idx);
         XRCCTRL(*this, "btnAddCompiler",        wxButton)->Enable(en);
         XRCCTRL(*this, "btnRenameCompiler",     wxButton)->Enable(en && count);
         XRCCTRL(*this, "btnDelCompiler",        wxButton)->Enable(en &&
« Last Edit: September 22, 2008, 09:56:35 am by stahta01 »
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: Patch for what I think is an coding bug in compileroptionsdlg.cpp
« Reply #1 on: September 19, 2008, 08:47:13 am »
Patch that I think is needed
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