Thank you. I was able to reproduce the problem.
In fact there are two problems here:
1. The crash happens because of nullptr dereference.
This patch tries to fix it
Index: src/plugins/compilergcc/compilergcc.cpp
===================================================================
--- src/plugins/compilergcc/compilergcc.cpp (revision 9573)
+++ src/plugins/compilergcc/compilergcc.cpp (working copy)
@@ -2913,6 +2913,14 @@ int CompilerGCC::CompileFileWithoutProject(const wxString& file)
int CompilerGCC::CompileFileDefault(cbProject* project, ProjectFile* pf, ProjectBuildTarget* bt)
{
Compiler* compiler = CompilerFactory::GetCompiler(bt->GetCompilerID());
+ if (!compiler)
+ {
+ const wxString &err = wxString::Format(_("error: Cannot build file for target '%s'. Compiler '%s' cannot be found!"),
+ bt->GetTitle().wx_str(), bt->GetCompilerID().wx_str());
+ LogMessage(pf->relativeToCommonTopLevelPath + _(": ") + err, cltError);
+ LogWarningOrError(cltError, project, pf->relativeToCommonTopLevelPath, wxEmptyString, err);
+ return -3;
+ }
DirectCommands dc(this, compiler, project, m_PageIndex);
wxArrayString compile = dc.CompileFile(bt, pf);
2. The second problem is that the target points to the invalid windows target, but in the compiler toolbar I see that the linux target is selected.
It seems that the CompilerGCC::GetBuildTargetForFile doesn't respect the non-supported target, so and it returns a windows only target on
linux and vise-versa. The problem seems to go away with this patch:
Index: src/plugins/compilergcc/compilergcc.cpp
===================================================================
--- src/plugins/compilergcc/compilergcc.cpp (revision 9573)
+++ src/plugins/compilergcc/compilergcc.cpp (working copy)
@@ -2855,7 +2855,12 @@ ProjectBuildTarget* CompilerGCC::GetBuildTargetForFile(ProjectFile* pf)
bt = m_pProject->GetBuildTarget(idx);
}
else // use the currently selected build target
- bt = m_pProject->GetBuildTarget(m_RealTargetIndex); // pick the selected target
+ {
+ const wxString &targetName = m_Targets[m_TargetIndex];
+ if (std::find(pf->buildTargets.begin(), pf->buildTargets.end(), targetName) == pf->buildTargets.end())
+ return nullptr;
+ bt = m_pProject->GetBuildTarget(targetName);
+ }
return bt;
}
@devs: Please comment, because I'm not too familiar with the Compiler's plugin, so I might be doing stupid things.