User forums > Using Code::Blocks

Hiccups while typing (continuation)

<< < (3/8) > >>

ollydbg:

--- Code: ---// ----------------------------------------------------------------------------
void ClassBrowser::SetParser(ParserBase* parser)
// ----------------------------------------------------------------------------
{
    if (m_Parser == parser)
        return;

    m_Parser = parser;
    if (m_Parser)
    {
        const int sel = XRCCTRL(*this, "cmbView", wxChoice)->GetSelection();
        BrowserDisplayFilter filter = static_cast<BrowserDisplayFilter>(sel);
        if (!m_ParseManager->IsParserPerWorkspace() && filter == bdfWorkspace)
            filter = bdfProject;

        m_Parser->ClassBrowserOptions().displayFilter = filter;
        m_Parser->WriteOptions();
        UpdateClassBrowserView();
    }
    else
        CCLogger::Get()->DebugLog("SetParser: No parser available.");
}

--- End code ---

It looks like the "last Parser's option" is written to the configure file.

So, can we add a check here in the line 245 of the file: plugins\codecompletion\classbrowser.cpp

I mean if it is a dummy parser(temp parser), we won't need to save the parser's option?

Because when a cbp project get closed, the dummy parser is always active, so the dummy parser's option is always saved when I close the C::B. (But this has some issue, when user open C::B without opening any cbp file, all the option is saved to dummy parser)

Another method is that we can copy the option of a closed project to the dummy parser's option, so that the dummy parser's option will be the same as the last cbp project's option when get closed.

Elena:
For me, the only way for the option to stay un-checked is opening C::B with no projects, un-checking it, closing C::B. Every project opened then will maintain the setting.

ollydbg:
When the workspace get closed(in the workspace close event handler), the below function will be called:


--- Code: ---bool ParseManager::DeleteParser(cbProject* project)
{
    wxString prj = (project ? project->GetTitle() : _T("*NONE*"));

    ParserList::iterator it = m_ParserList.begin();
    if (!m_ParserPerWorkspace)
    {
        for (; it != m_ParserList.end(); ++it)
        {
            if (it->first == project)
                break;
        }
    }

    if (it == m_ParserList.end())
    {
        CCLogger::Get()->DebugLog(wxString::Format("ParseManager::DeleteParser: Parser does not exist for delete '%s'!", prj));
        return false;
    }

    bool removeProjectFromParser = false;
    if (m_ParserPerWorkspace)
        removeProjectFromParser = RemoveProjectFromParser(project);

    if (m_ParsedProjects.empty()) // this indicates we are in one parser per one project mode
    {
        wxString log(wxString::Format(_("ParseManager::DeleteParser: Deleting parser for project '%s'!"), prj));
        CCLogger::Get()->Log(log);
        CCLogger::Get()->DebugLog(log);

        // the logic here is : firstly delete the parser instance, then see whether we need an
        // active parser switch (call SetParser())
        delete it->second;

        // if the active parser is deleted, set the active parser to nullptr
        if (it->second == m_Parser)
        {
            m_Parser = nullptr;
            SetParser(m_TempParser); // Also updates class browser
        }

        m_ParserList.erase(it);

        return true;
    }

    if (removeProjectFromParser)
        return true;

    CCLogger::Get()->DebugLog(_T("ParseManager::DeleteParser: Deleting parser failed!"));
    return false;
}

--- End code ---

Note that there is a line:


--- Code: ---SetParser(m_TempParser); // Also updates class browser
--- End code ---

In this case, the dummy parser is set as the "active parser". So, in the final stage, this dummy parser's option will be saved to the config file, not the last active project in the workspace.

Pecan:
@ ollydbg

I'll test out your suggestions today. Thanks.

I'll test with NO project, then one, then multiple projects and see if checking for the dummy (first) parser works.

Another thought might be to issue a shared event to tell all parsers to re-read (update its parser.options) if a user clicks OK in the CodeCompletion settings dialog.

I don't mean to create a new global event, but I know that an event using an XRCID("mySharedEventId") is possible if both sender and receiver use the same XRCID.

Pecan:
@ ollydbg

How about this idea.

The ccoptionsdlg can always record, in a global var, the address of the active parser that last updated the settings.

When the workspace is closed, if that var contains an address, that parser will be the only parser that is allows to update the .conf settings.

That way, any number of projects can be in the workspace, but only the last parser to update the settings can finally store them to the .conf .

Wouldn't that work for only one parser and also for multiple parsers?

If the global var is nullptr, ccoptionsdlg never got called to change any option, then we don't care about which parser updates the .conf .

ccoptionsdlg would only set the active parsers address in the global var, if the user clicked OK to dismiss the dialog.
I'm assuming that the dismiss dialog action (OK or Cancel) can be caught.
Else we'd have to find another way to determine that the user changed any option.

Edit: 10:35am
Got It. void CCOptionsDlg::OnApply() is only called when user clicks OK. I'm thinking that's the only place we need to set the global var with the active parser address.



Is all this true?

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version