News:

Accounts with zero posts and zero activity during the last months will be deleted periodically to fight SPAM!

Main Menu

swap between a header file and a implementation file problem

Started by ollydbg, May 11, 2010, 04:02:39 AM

Previous topic - Next topic

ollydbg

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.

hakim

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.

ollydbg

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???
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.

Loaden

I solved this problem, I will create a patch based on CC branch. :D

ollydbg

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.