...found a bug (which crashes C::B):
If you have a virtual target active, this line:
wxFileName objname(prj->GetBuildTarget(prj->GetActiveBuildTarget())->GetObjectOutput() + sep + prjfile->GetObjName());
...in void cbGcov::GcovProject(cbProject* prj) will crash C::B because prj->GetBuildTarget(prj->GetActiveBuildTarget()) will be a NULL pointer. You cannot rely on obtaining a valid build target always, so you need to verify this.
Edit: Also, in the same method I see two more crash candidates:
Accessing a project pointer without verification:
void cbGcov::GcovProject(cbProject* prj)
{
m_JobsWorkingdir = prj->GetBasePath();
...accessing a project file pointer without verification:
ProjectFile *prjfile = prj->GetFile(k);
if(prjfile->compile)
Be careful! Always verify what you get.
Hi
One more update, possibly a final one :)
* Checking more pointers for validity, as suggested.
* Clean project/workspace removes the corresponding .gcno .gcda files
* When running cbGcov on workspace, after each project is finished the open editor windows are updated for that project
Known limitation: Newly opening an editor window will update it with gcov info only if it is a part of the currently active project. This should not be a problem, if I could get cbProject* in cbGcov::OnEditorOpen()
void cbGcov::OnEditorOpen(CodeBlocksEvent &event)
{
EditorBase * eb = event.GetEditor();
cbProject* prj = event.GetProject(); // this is always null?
if(!eb || !eb->IsBuiltinEditor())
{
return;
}
cbEditor *ed = Manager::Get()->GetEditorManager()->GetBuiltinEditor(eb);
if(!ed)
{
return;
}
if (!prj && ed->GetProjectFile()) // ed->GetProjectFile() always NULL too?
{
prj = ed->GetProjectFile()->GetParentProject();
}
ShowCovData(ed,prj);
}
I am unable to get the cbProject out of the event even when the file opened does belong to a project. How can I do that?
Or... should I really build the proper SDK? ;)
One more update, possibly a final one :)
not really, unfortunately. The crash remains as you did only half the way.
This line:
wxString objOutput = prj->GetBuildTarget(prj->GetActiveBuildTarget())->GetObjectOutput();
...in void cbGcov::CleanProject(cbProject* prj) will still crash if you have activated a virtual target.
You also need to verify the return value of:
prj->GetBuildTarget(prj->GetActiveBuildTarget())
...as I had written btw..
The idea is good, but I really think this plugin needs way more testing. I was my #1 crash candidate the last couple of days even I did no use it. :?
...also, this: _(".gcda") makes no sense. You don't want to translate the file extension, don't you? use _T() or wxT() instead for strings you don't want to translate... but that's only minor.