Author Topic: swap between a header file and a implementation file problem  (Read 8636 times)

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5931
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
I find a problem, If I open the Codeblocks.cbp, and open the file:
sdk\cbeditor.cpp

Then, you will see NO cbEditor entry in the CC's symbol browser.  (The options is: Current files symbols)

But once you do a swap to open the header file, which is
include\cbeditor.h

Then, you will see the cbEditor class information in the CC's symbol browser.

This means: the current way of doing header/implementation files can be improved.
At least, when we open cbeditor.cpp, the symbol tree should show the cbEditor.

right?
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline hakim

  • Single posting newcomer
  • *
  • Posts: 9
Re: swap between a header file and a implementation file problem
« Reply #1 on: May 13, 2010, 11:47:16 am »
Yup, that's the regression I reported here a bit earlier. It would be really nice if someone fixed it. BTW, it's just symbol browser bug - everything works just fine in code completion toolbar.

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5931
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: swap between a header file and a implementation file problem
« Reply #2 on: May 13, 2010, 02:40:58 pm »
The code snippet about this problem is show below.
In the classbrowser.cpp

Code
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.
Code
a:\abc\def\hij.cpp
a:\abc\def\hij.h

Then, open either the header file or the cpp file, you will get the
Code
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???
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline Loaden

  • Lives here!
  • ****
  • Posts: 1014
Re: swap between a header file and a implementation file problem
« Reply #3 on: August 03, 2010, 04:34:56 pm »
I solved this problem, I will create a patch based on CC branch. :D

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5931
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: swap between a header file and a implementation file problem
« Reply #4 on: August 03, 2010, 04:42:45 pm »
I solved this problem, I will create a patch based on CC branch. :D
Nice work!!!
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.