With the 'compilergcc' plugin in 'int CompilerGCC::Run(ProjectBuildTarget* target)' we find
Manager::Get()->GetLogManager()->Log(_("Checking for existence: ") + f.GetFullPath(), m_PageIndex);
if ( (target->GetTargetType() != ttCommandsOnly) && !wxFileExists(f.GetFullPath()) )
{
int ret = cbMessageBox(_("It seems that this project has not been built yet.\n"
"Do you want to build it now?"),
_("Information"),
wxYES_NO | wxCANCEL | wxICON_QUESTION);
switch (ret)
{
case wxID_YES:
{
m_pProject->SetCurrentlyCompilingTarget(0);
m_RunAfterCompile = true;
Build(target);
return -1;
}
case wxID_NO:
break;
default:
m_pProject->SetCurrentlyCompilingTarget(0);
return -1;
}
}
This verifies that the executable exists, because '&Run' has been activated.
Instead, '&Run' should be invalidated if the executable does not exist. This could be done automatically in
'void CompilerGCC::OnUpdateUI(wxUpdateUIEvent& event)' by :
...
cbProject* prj = projectManager->GetActiveProject();
cbEditor* ed = Manager::Get()->GetEditorManager()->GetBuiltinActiveEditor();
/// new
if (id == idMenuRun)
{
event.Enable(exeExists(prj));
}
else
...
with 'exeExists(prj)' which would indicate whether the executable exists for example :
bool CompilerGCC::exeExists(cbProject* prj)
{
bool valid = false;
if (prj)
{
ProjectBuildTarget* pTarget = prj->GetBuildTarget(prj->GetActiveBuildTarget());
if (pTarget)
{
wxString out = UnixFilename(pTarget->GetOutputFilename());
Manager::Get()->GetMacrosManager()->ReplaceEnvVars(out);
wxFileName file(out);
file.MakeAbsolute(prj->GetBasePath());
valid = ::wxFileExists(file.GetFullPath());
valid = valid || (pTarget->GetTargetType() == ttCommandsOnly) ;
}
}
return valid;
}
This approach seems to me to be more correct than checking afterwards whether the action taken is correct.
Because in the options allowed to the user: the option 'wxID_NO' leads to run anyway with an error !!
What do you think about this?