Compiler Options Dialog Update
Compiler Options Dialog Update
cpp
===================================================================
@@ -209,34 +209,34 @@
public:
private:
- int m_data;
+ Compiler* m_data;
};
namespace
{
if (!choice || (n == -1))
- return -1;
+ return nullptr;
if (!choice)
- return -1;
+ return nullptr;
if (choice)
@@ -244,7 +244,7 @@
- if (GetIndex(choice, n) == index)
+ if (GetCompiler(choice, n) == val)
position = n;
break;
@@ -255,9 +255,9 @@
return position;
if (choice)
choice->SetSelection(pos);
@@ -278,7 +278,7 @@
m_FlagsPG(nullptr),
m_Compiler(compiler),
- m_CurrentCompilerIdx(0),
+ m_CurrentCompiler(nullptr),
m_pProject(project),
m_pTarget(target),
m_bDirty(false),
@@ -401,7 +401,7 @@
compilerIdx = 0;
DoFillCompilerSets(compilerIdx);
m_Options = CompilerFactory::GetCompiler(compilerIdx)->GetOptions();
- m_CurrentCompilerIdx = compilerIdx;
+ m_CurrentCompiler = CompilerFactory::GetCompiler(compilerIdx);
DoFillCompilerDependentSettings();
@@ -462,7 +462,7 @@
if (i == defaultCompilerIdx)
@@ -476,7 +476,7 @@
// if (!CompilerFactory::GetCompiler(compilerIdx))
// compilerIdx = 0;
// m_Options = CompilerFactory::GetCompiler(compilerIdx)->GetOptions();
- SetSelection(cmb, compilerIdx);
+ SetSelection(cmb, CompilerFactory::GetCompiler(compilerIdx));
// m_CurrentCompilerIdx = compilerIdx;
} // DoFillCompilerSets
@@ -532,12 +532,11 @@
if (m_pProject)
- if (!compiler)
+ if (!m_CurrentCompiler)
return;
@@ -570,7 +569,7 @@
} // DoFillCompilerPrograms
@@ -760,8 +759,6 @@
wxString rest;
unsigned int i = 0;
@@ -775,7 +772,7 @@
copt->enabled = true;
m_CompilerOptions.RemoveAt(i, 1);
// definition
// global options
- if (compiler)
+ if (m_CurrentCompiler)
- IncludeDirs = compiler->GetIncludeDirs();
- ResDirs = compiler->GetResourceIncludeDirs();
- LibDirs = compiler->GetLibDirs();
- m_CompilerOptions = compiler->GetCompilerOptions();
- m_ResourceCompilerOptions = compiler->GetResourceCompilerOptions();
- m_LinkerOptions = compiler->GetLinkerOptions();
- m_LinkLibs = compiler->GetLinkLibs();
+ IncludeDirs = m_CurrentCompiler->GetIncludeDirs();
+ ResDirs = m_CurrentCompiler->GetResourceIncludeDirs();
+ LibDirs = m_CurrentCompiler->GetLibDirs();
+ m_CompilerOptions = m_CurrentCompiler->GetCompilerOptions();
+ m_ResourceCompilerOptions = m_CurrentCompiler->GetResourceCompilerOptions();
+ m_LinkerOptions = m_CurrentCompiler->GetLinkerOptions();
+ m_LinkLibs = m_CurrentCompiler->GetLinkLibs();
if (cmbLogging)
- cmbLogging->SetSelection((int)compiler->GetSwitches().logging);
+ cmbLogging->SetSelection((int)m_CurrentCompiler->GetSwitches().logging);
cmbLinkerExe->Show(false);
@@ -988,7 +984,7 @@
@@ -1077,23 +1073,22 @@
// global options
- if (compiler)
+ if (m_CurrentCompiler)
- compiler->SetIncludeDirs(IncludeDirs);
- compiler->SetLibDirs(LibDirs);
- compiler->SetResourceIncludeDirs(ResDirs);
- compiler->SetCompilerOptions(m_CompilerOptions);
- compiler->SetResourceCompilerOptions(m_ResourceCompilerOptions);
- compiler->SetLinkerOptions(m_LinkerOptions);
- compiler->SetLinkLibs(m_LinkLibs);
+ m_CurrentCompiler->SetIncludeDirs(IncludeDirs);
+ m_CurrentCompiler->SetLibDirs(LibDirs);
+ m_CurrentCompiler->SetResourceIncludeDirs(ResDirs);
+ m_CurrentCompiler->SetCompilerOptions(m_CompilerOptions);
+ m_CurrentCompiler->SetResourceCompilerOptions(m_ResourceCompilerOptions);
+ m_CurrentCompiler->SetLinkerOptions(m_LinkerOptions);
+ m_CurrentCompiler->SetLinkLibs(m_LinkLibs);
if (cmb)
[Link] = (CompilerLoggingType)cmb->GetSelection();
- compiler->SetSwitches(switches);
+ m_CurrentCompiler->SetSwitches(switches);
@@ -1174,8 +1169,7 @@
void CompilerOptionsDlg::DoSaveCompilerPrograms()
return;
CompilerPrograms progs;
@@ -1193,8 +1187,8 @@
[Link] = data->GetData();
- compiler->SetPrograms(progs);
- compiler->SetMasterPath(masterPath);
+ m_CurrentCompiler->SetPrograms(progs);
+ m_CurrentCompiler->SetMasterPath(masterPath);
if (control)
@@ -1202,7 +1196,7 @@
wxArrayString extraPaths;
ListBox2ArrayString(extraPaths, control);
- compiler->SetExtraPaths(extraPaths);
+ m_CurrentCompiler->SetExtraPaths(extraPaths);
}
} // DoSaveCompilerPrograms
@@ -1246,145 +1240,144 @@
void CompilerOptionsDlg::DoSaveCompilerDefinition()
node->AddAttribute(name, wxT("C"));
- node->AddAttribute(value, compiler->GetPrograms().C);
+ node->AddAttribute(value, m_CurrentCompiler->GetPrograms().C);
node = node->GetNext();
node->AddAttribute(name, wxT("CPP"));
- node->AddAttribute(value, compiler->GetPrograms().CPP);
+ node->AddAttribute(value, m_CurrentCompiler->GetPrograms().CPP);
node = node->GetNext();
node->AddAttribute(name, wxT("LD"));
- node->AddAttribute(value, compiler->GetPrograms().LD);
+ node->AddAttribute(value, m_CurrentCompiler->GetPrograms().LD);
node->AddAttribute(name, wxT("DBGconfig"));
- node->AddAttribute(value, compiler->GetPrograms().DBGconfig);
+ node->AddAttribute(value, m_CurrentCompiler->GetPrograms().DBGconfig);
node = node->GetNext();
node->AddAttribute(name, wxT("LIB"));
- node->AddAttribute(value, compiler->GetPrograms().LIB);
+ node->AddAttribute(value, m_CurrentCompiler->GetPrograms().LIB);
node = node->GetNext();
node->AddAttribute(name, wxT("WINDRES"));
- node->AddAttribute(value, compiler->GetPrograms().WINDRES);
+ node->AddAttribute(value, m_CurrentCompiler->GetPrograms().WINDRES);
node = node->GetNext();
node->AddAttribute(name, wxT("MAKE"));
- node->AddAttribute(value, compiler->GetPrograms().MAKE);
+ node->AddAttribute(value, m_CurrentCompiler->GetPrograms().MAKE);
node = node->GetNext();
node->AddAttribute(name, wxT("includeDirs"));
- node->AddAttribute(value, compiler->GetSwitches().includeDirs);
+ node->AddAttribute(value, m_CurrentCompiler->GetSwitches().includeDirs);
node = node->GetNext();
node->AddAttribute(name, wxT("libDirs"));
- node->AddAttribute(value, compiler->GetSwitches().libDirs);
+ node->AddAttribute(value, m_CurrentCompiler->GetSwitches().libDirs);
node = node->GetNext();
node->AddAttribute(name, wxT("linkLibs"));
- node->AddAttribute(value, compiler->GetSwitches().linkLibs);
+ node->AddAttribute(value, m_CurrentCompiler->GetSwitches().linkLibs);
node = node->GetNext();
node->AddAttribute(name, wxT("defines"));
- node->AddAttribute(value, compiler->GetSwitches().defines);
+ node->AddAttribute(value, m_CurrentCompiler->GetSwitches().defines);
node = node->GetNext();
node->AddAttribute(name, wxT("genericSwitch"));
- node->AddAttribute(value, compiler->GetSwitches().genericSwitch);
+ node->AddAttribute(value, m_CurrentCompiler->GetSwitches().genericSwitch);
node = node->GetNext();
node->AddAttribute(name, wxT("objectExtension"));
- node->AddAttribute(value, compiler->GetSwitches().objectExtension);
+ node->AddAttribute(value, m_CurrentCompiler->GetSwitches().objectExtension);
node = node->GetNext();
node->AddAttribute(name, wxT("forceFwdSlashes"));
node = node->GetNext();
node->AddAttribute(name, wxT("forceLinkerUseQuotes"));
node = node->GetNext();
node->AddAttribute(name, wxT("forceCompilerUseQuotes"));
+ node->AddAttribute(value, (m_CurrentCompiler->GetSwitches().forceCompilerUseQuotes ?
wxT("true") : wxT("false")));
node = node->GetNext();
node->AddAttribute(name, wxT("needDependencies"));
node = node->GetNext();
node->AddAttribute(name, wxT("logging"));
- if (compiler->GetSwitches().logging == CompilerSwitches::defaultLogging)
+ if (m_CurrentCompiler->GetSwitches().logging == CompilerSwitches::defaultLogging)
node->AddAttribute(value, wxT("default"));
node->AddAttribute(value, wxT("full"));
node->AddAttribute(value, wxT("simple"));
node->AddAttribute(value, wxT("none"));
node = node->GetNext();
node->AddAttribute(name, wxT("libPrefix"));
- node->AddAttribute(value, compiler->GetSwitches().libPrefix);
+ node->AddAttribute(value, m_CurrentCompiler->GetSwitches().libPrefix);
node = node->GetNext();
node->AddAttribute(name, wxT("libExtension"));
- node->AddAttribute(value, compiler->GetSwitches().libExtension);
+ node->AddAttribute(value, m_CurrentCompiler->GetSwitches().libExtension);
node->SetNext(new wxXmlNode(wxXML_ELEMENT_NODE, wxT("Switch")));
node = node->GetNext();
node->AddAttribute(name, wxT("linkerNeedsLibPrefix"));
node = node->GetNext();
node->AddAttribute(name, wxT("linkerNeedsLibExtension"));
+ node->AddAttribute(value, (m_CurrentCompiler->GetSwitches().linkerNeedsLibExtension ?
wxT("true") : wxT("false")));
node = node->GetNext();
node->AddAttribute(name, wxT("linkerNeedsPathResolved"));
+ node->AddAttribute(value, (m_CurrentCompiler->GetSwitches().linkerNeedsPathResolved ?
wxT("true") : wxT("false")));
node = node->GetNext();
node->AddAttribute(name, wxT("supportsPCH"));
node->AddAttribute(name, wxT("PCHExtension"));
- node->AddAttribute(value, compiler->GetSwitches().PCHExtension);
+ node->AddAttribute(value, m_CurrentCompiler->GetSwitches().PCHExtension);
node = node->GetNext();
node->AddAttribute(name, wxT("UseFlatObjects"));
node = node->GetNext();
node->AddAttribute(name, wxT("UseFullSourcePaths"));
node = node->GetNext();
node->AddAttribute(name, wxT("includeDirSeparator"));
- node->AddAttribute(value, compiler->GetSwitches().includeDirSeparator);
+ node->AddAttribute(value, m_CurrentCompiler->GetSwitches().includeDirSeparator);
node = node->GetNext();
node->AddAttribute(name, wxT("libDirSeparator"));
- node->AddAttribute(value, compiler->GetSwitches().libDirSeparator);
+ node->AddAttribute(value, m_CurrentCompiler->GetSwitches().libDirSeparator);
node->SetNext(new wxXmlNode(wxXML_ELEMENT_NODE, wxT("Switch")));
node = node->GetNext();
node->AddAttribute(name, wxT("objectSeparator"));
- node->AddAttribute(value, compiler->GetSwitches().objectSeparator);
+ node->AddAttribute(value, m_CurrentCompiler->GetSwitches().objectSeparator);
node = node->GetNext();
node->AddAttribute(name, wxT("statusSuccess"));
node = node->GetNext();
node->AddAttribute(name, wxT("Use83Paths"));
@@ -1417,7 +1410,7 @@
if (i == ctCompileObjectCmd)
op = wxT("CompileObject");
@@ -1448,7 +1441,7 @@
@@ -1476,17 +1469,17 @@
- if (!compiler->GetCOnlyFlags().IsEmpty())
+ if (!m_CurrentCompiler->GetCOnlyFlags().IsEmpty())
node = node->GetNext();
- node->AddAttribute(wxT("CFlags"), compiler->GetCOnlyFlags());
+ node->AddAttribute(wxT("CFlags"), m_CurrentCompiler->GetCOnlyFlags());
- if (!compiler->GetCPPOnlyFlags().IsEmpty())
+ if (!m_CurrentCompiler->GetCPPOnlyFlags().IsEmpty())
node = node->GetNext();
- node->AddAttribute(wxT("CPPFlags"), compiler->GetCPPOnlyFlags());
+ node->AddAttribute(wxT("CPPFlags"), m_CurrentCompiler->GetCPPOnlyFlags());
wxXmlDocument doc;
@@ -1497,10 +1490,10 @@
if (!wxDirExists(folder))
wxMkdir(folder);
- [Link](folder+"/options_"+compiler->GetID()+".xml");
+ [Link](folder+"/options_"+m_CurrentCompiler->GetID()+".xml");
- compiler->SetOptions(m_Options);
+ m_CurrentCompiler->SetOptions(m_Options);
} // DoSaveCompilerDefinition
// events
@@ -1531,7 +1524,7 @@
- UpdateCompilerForTargets(m_CurrentCompilerIdx);
+ UpdateCompilerForTargets(m_CurrentCompiler);
@@ -1552,21 +1545,22 @@
return;
- (data->GetProject() ? CompilerFactory::GetCompilerIndex(data->GetProject()-
>GetCompilerID()) :
- GetSelectionIndex(cmb));
+ (data->GetProject() ? CompilerFactory::GetCompiler(data->GetProject()-
>GetCompilerID()) :
+ GetSelectionCompiler(cmb));
// in order to support projects/targets which have an unknown "user compiler", that is on the current
- // system that compiler is not (or no longer) installed, we should check the compilerIdx, in such a
case it will
+ // system that compiler is not (or no longer) installed, we should check the compiler, in such a case it
will
+ // be 'nullptr' [NOTE : maybe to the check already on the Id ?]
// b) leave that compiler --> no settings can be set then (done by disabling the notebook,
// as a consequence might need to be re-enabled when another target/project is chosen in the tree)
- if (compilerIdx != -1)
+ if (compiler)
- SetSelection(cmb, compilerIdx);
+ SetSelection(cmb, compiler);
m_pTarget = data->GetTarget();
@@ -1602,10 +1596,9 @@
// the new selection might have a different compiler settings and/or even a different compiler
- m_CurrentCompilerIdx = compilerIdx;
- if (compiler)
- m_Options = compiler->GetOptions();
+ m_CurrentCompiler = compiler;
+ if (m_CurrentCompiler)
+ m_Options = m_CurrentCompiler->GetOptions();
DoFillCompilerDependentSettings();
@@ -1618,7 +1611,6 @@
"Please choose the compiler you want to use instead and click \"OK\".\n"
"If you click \"Cancel\", the project/target will remain configured for that compiler and
consequently can not be configured and will not be built."),
CompilerId.wx_str());
compiler = CompilerFactory::SelectCompilerUI(msg);
@@ -1626,7 +1618,7 @@
{ // a new compiler was chosen, proceed as if the user manually selected another compiler
- SetSelection(cmb, CompilerFactory::GetCompilerIndex(compiler));
+ SetSelection(cmb,compiler);
wxCommandEvent Dummy;
OnCompilerChanged(Dummy);
@@ -1705,7 +1697,7 @@
wxICON_EXCLAMATION|wxYES|wxNO|wxCANCEL))
case wxID_CANCEL :
bChanged = false;
break;
case wxID_YES :
@@ -1730,7 +1722,7 @@
void CompilerOptionsDlg::CompilerChanged()
// in case we are not on the global level (== project/target) we need to remember this switch
// so that on "SAVE" time we can adjust the project/target with it's new compiler
// SAVE time for this particular setting means (Apply or TreeSelection change
@@ -1737,18 +1729,17 @@
// not compiler change since we could (re)change the compiler of that project/target
if (m_pProject)
- m_NewProjectOrTargetCompilerId = CompilerFactory::GetCompiler(m_CurrentCompilerIdx)-
>GetID();
+ m_NewProjectOrTargetCompilerId = m_CurrentCompiler->GetID();
//load the new options (== options of the new selected compiler)
- if (compiler)
- m_Options = compiler->GetOptions();
+ if (m_CurrentCompiler)
+ m_Options = m_CurrentCompiler->GetOptions();
DoFillCompilerDependentSettings();
} // CompilerChanged
int ret = cbMessageBox(_("You have changed the compiler used for the project.\n"
"Do you want to use the same compiler for all the project's build targets too?"),
@@ -1759,7 +1750,6 @@
if (compiler)
target->SetCompilerID(compiler->GetID());
@@ -1768,22 +1758,21 @@
void CompilerOptionsDlg::AutoDetectCompiler()
- if (!compiler)
+ if (!m_CurrentCompiler)
return;
wxArrayString empty;
- compiler->SetExtraPaths(empty);
+ m_CurrentCompiler->SetExtraPaths(empty);
- switch (compiler->AutoDetectInstallationDir())
+ switch (m_CurrentCompiler->AutoDetectInstallationDir())
case adrDetected:
wxString msg;
cbMessageBox(msg);
break;
@@ -1792,12 +1781,12 @@
{
wxString msg;
- compiler->GetName().wx_str());
+ m_CurrentCompiler->GetName().wx_str());
- compiler->SetMasterPath(backup);
- compiler->SetExtraPaths(ExtraPathsBackup);
+ m_CurrentCompiler->SetMasterPath(backup);
+ m_CurrentCompiler->SetExtraPaths(ExtraPathsBackup);
break;
@@ -1805,9 +1794,9 @@
default:
break;
} // AutoDetectCompiler
@@ -1834,7 +1823,7 @@
: (m_pProject ? m_pProject
- : (CompileOptionsBase*)(CompilerFactory::GetCompiler(m_CurrentCompilerIdx)));
+ : (CompileOptionsBase*)m_CurrentCompiler);
} // GetVarsOwner
@@ -2182,15 +2171,13 @@
- CompilerFactory::SetDefaultCompiler(idx);
+ CompilerFactory::SetDefaultCompiler(compiler);
wxString msg;
[Link](_("%s is now selected as the default compiler for new projects"), compiler ? compiler-
>GetName() : _("[invalid]"));
cbMessageBox(msg);
-
- DoFillCompilerSets(idx);
+ DoFillCompilerSets(CompilerFactory::GetCompilerIndex(compiler));
} // OnSetDefaultCompilerClick
@@ -2220,7 +2207,7 @@
- wxString::Format(_("Copy of %s"),
CompilerFactory::GetCompiler(m_CurrentCompilerIdx)->GetName()),
+ wxString::Format(_("Copy of %s"),m_CurrentCompiler->GetName()),
this);
if (![Link]())
@@ -2228,7 +2215,7 @@
try
- newC =
CompilerFactory::CreateCompilerCopy(CompilerFactory::GetCompiler(m_CurrentCompilerIdx), value);
catch (cbException& e)
@@ -2245,10 +2232,10 @@
}
else
- m_CurrentCompilerIdx = CompilerFactory::GetCompilerIndex(newC);
+ m_CurrentCompiler = newC;
- SetSelection(cmb, m_CurrentCompilerIdx);
+ SetSelection(cmb, m_CurrentCompiler);
DoFillCompilerDependentSettings();
cbMessageBox(_("The new compiler has been added! Don't forget to update the \"Toolchain
executables\" page..."));
@@ -2264,22 +2251,41 @@
- if (compiler)
+ if (m_CurrentCompiler)
- compiler->SetName(newValue);
- if (compiler == CompilerFactory::GetDefaultCompiler())
- cmb->Delete(GetIndexPosition(cmb, m_CurrentCompilerIdx));
- cmb->SetSelection(pos);
+ try
+ {
+ }
+ catch (cbException& e)
+ {
+ [Link](false);
+ }
+ if (!newC)
+ {
+ cbMessageBox(_("The compiler could not be renamed.\n(maybe a compiler with the same
name already exists?)"),
+ _("Error"), wxICON_ERROR);
+ return;
+ }
+ CompilerFactory::RemoveCompiler(m_CurrentCompiler);
+ if (m_CurrentCompiler==CompilerFactory::GetDefaultCompiler())
+ CompilerFactory::SetDefaultCompiler(newC);
+ m_CurrentCompiler=newC;
+ DoFillCompilerSets(CompilerFactory::GetCompilerIndex(m_CurrentCompiler));
+ DoFillCompilerDependentSettings();
} // OnEditCompilerClick
@@ -2292,27 +2298,15 @@
- CompilerFactory::RemoveCompiler(CompilerFactory::GetCompiler(m_CurrentCompilerIdx));
+ CompilerFactory::RemoveCompiler(m_CurrentCompiler);
cmb->Delete(pos);
- {
- if (data)
- {
- data->SetData(idx-1);
- }
- }
// Select next compiler in the choice or last if the deleted one was the last
- m_CurrentCompilerIdx = GetSelectionIndex(cmb);
+ m_CurrentCompiler = GetSelectionCompiler(cmb);
DoFillCompilerDependentSettings();
} // OnRemoveCompilerClick
@@ -2327,16 +2321,15 @@
_("Confirmation"),
- if (compiler)
+ if (m_CurrentCompiler)
if ( wxFileExists(ConfigManager::GetDataFolder(true) + file)
wxRemoveFile(ConfigManager::GetDataFolder(false) + file);
- compiler->Reset();
+ m_CurrentCompiler->Reset();
// run auto-detection
AutoDetectCompiler();
@@ -2802,8 +2795,8 @@
wxART_QUESTION);
if ([Link]() == AnnoyingDialog::rtYES)
PlaceWindow(&dlg2);
[Link]();
// check if dirty
@@ -2900,13 +2893,12 @@
compiler &&
!compiler->GetParentID().IsEmpty());
@@ -2922,7 +2914,7 @@
void CompilerOptionsDlg::OnApply()
DoSaveCompilerDependentSettings();
CompilerFactory::SaveSettings();
@@ -3102,9 +3094,8 @@
return;
if (m_MenuOption == FMO_COnly)
wxTextEntryDialog dlg(this, _("List flags that will only be used during C compilation"),
@@ -3118,9 +3109,9 @@
- if (flags != compiler->GetCOnlyFlags())
+ if (flags != m_CurrentCompiler->GetCOnlyFlags())
- compiler->SetCOnlyFlags(flags);
+ m_CurrentCompiler->SetCOnlyFlags(flags);
m_bDirty = true;
return;
@@ -3127,9 +3118,8 @@
wxTextEntryDialog dlg(this, _("List flags that will only be used during C++ compilation"),
@@ -3143,9 +3133,9 @@
- if (flags != compiler->GetCPPOnlyFlags())
+ if (flags != m_CurrentCompiler->GetCPPOnlyFlags())
- compiler->SetCPPOnlyFlags(flags);
+ m_CurrentCompiler->SetCPPOnlyFlags(flags);
m_bDirty = true;
return;
Index: src/plugins/compilergcc/compileroptionsdlg.h
===================================================================
@@ -65,7 +65,7 @@
void DoSaveVars();
void DoSaveCompilerDefinition();
void CompilerChanged();
void AutoDetectCompiler();
wxListBox* GetDirsListBox();
CompileOptionsBase* GetVarsOwner();
@@ -127,7 +127,7 @@
wxArrayString m_LinkLibs;
wxArrayString m_CompilerOptions;
wxArrayString m_ResourceCompilerOptions;
- int m_CurrentCompilerIdx;
+ Compiler * m_CurrentCompiler;
cbProject* m_pProject;
ProjectBuildTarget* m_pTarget;
bool m_bDirty; //!< true if a setting has changed since last save