The code snippet about this problem is show below.
In the classbrowser.cpp
void ClassBrowser::UpdateView(bool checkHeaderSwap)
{
m_pActiveProject = 0;
TRACE(_T("ClassBrowser::UpdateView(), the old m_ActiveFilename = %s"),m_ActiveFilename.wx_str());
wxString oldActiveFilename = m_ActiveFilename;
m_ActiveFilename.Clear();
if (m_pParser && !Manager::IsAppShuttingDown())
{
m_pActiveProject = Manager::Get()->GetProjectManager()->GetActiveProject();
cbEditor* ed = Manager::Get()->GetEditorManager()->GetBuiltinActiveEditor();
if (ed)
{
//m_ActiveFilename = ed->GetFilename().BeforeLast(_T('.'));
// the above line is a bug (see https://developer.berlios.de/patch/index.php?func=detailpatch&patch_id=1559&group_id=5358)
m_ActiveFilename = ed->GetFilename().AfterLast(wxFILE_SEP_PATH);
if (m_ActiveFilename.Find(_T('.')) != wxNOT_FOUND)
{
m_ActiveFilename = ed->GetFilename().BeforeLast(wxFILE_SEP_PATH) + wxFILE_SEP_PATH + m_ActiveFilename.BeforeLast(_T('.'));
m_ActiveFilename.Append(_T('.'));
}
else
m_ActiveFilename = ed->GetFilename();
}
TRACE(_T("ClassBrowser::UpdateView(), the new m_ActiveFilename = %s"),m_ActiveFilename.wx_str());
if (checkHeaderSwap && oldActiveFilename.IsSameAs(m_ActiveFilename))
{
TRACE(_T("ClassBrowser::UpdateView() match the old filename, return!"));
return;
}
BuildTree();
wxSplitterWindow* splitter = XRCCTRL(*this, "splitterWin", wxSplitterWindow);
if (m_pParser->ClassBrowserOptions().treeMembers)
{
splitter->SplitHorizontally(m_Tree, m_TreeBottom);
m_TreeBottom->Show(true);
}
else
{
splitter->Unsplit();
m_TreeBottom->Show(false);
}
}
else
m_Tree->DeleteAllItems();
}
You will see, the function BuildTree() will build the tree control, basically depend on the variable: m_ActiveFilename
So, what does m_ActiveFilename means.
For example, you have these files in your project.
a:\abc\def\hij.cpp
a:\abc\def\hij.h
Then, open either the header file or the cpp file, you will get the
m_ActiveFilename = "a:\abc\def\hij."
So, a file search with prefix of "a:\abc\def\hij." will show all the tokens in both of the two files.
But this does not work if the header file and implementation file does
NOT in the same directory. (As they don't share the same prefix string")
How can we solve this problem???