Code::Blocks Forums

Developer forums (C::B DEVELOPMENT STRICTLY!) => Development => Topic started by: ollydbg on April 07, 2013, 02:32:39 am

Title: GetUserVariableManager().Exists() question
Post by: ollydbg on April 07, 2013, 02:32:39 am
I'm creating a wizard for OpenCV library, but have problem handling paths, so I read the related part of script in wxWidgets wizard, it is in <C::B>\share\CodeBlocks\templates\wizard\wxwidgets\wizard.script

Code
////////////////////////////////////////////////////////////////////////////////
// wxWidgets' path page
////////////////////////////////////////////////////////////////////////////////

function OnLeave_WxPath(fwd)
{
    if (fwd)
    {
        local dir         = Wizard.GetTextControlValue(_T("txtFolder"));
        local dir_nomacro = ReplaceMacros(dir, true);
        if (!IO.FileExists(dir_nomacro + _T("/include/wx/wx.h")))
        {
            ShowError(_T("The path you entered seems valid, but this wizard " +
                    "can't locate wxWidgets' files in it..."));
            return false;
        }

        // see if it matches the global var. if it does, use the var instead...
        if (GetUserVariableManager().Exists(_T("#wx")))
        {
            local gvar = ReplaceMacros(_T("$(#wx)"), true);
            if (gvar.Matches(dir_nomacro))
                dir = gvar;
        }
        WxPath = dir;
    }
    return true;
}

The question is: this function call
Code
GetUserVariableManager().Exists(_T("#wx"))
return false.

But I do have a global variable "wx" in C::B Menu->Settings->Global variables.

When reading the source, I see that:
Code
bool UserVariableManager::Exists(const wxString& variable) const
{
    if (variable.find(_T('#')) == wxString::npos)
        return false;

    wxString member(variable.AfterLast(wxT('#')).BeforeFirst(wxT('.')).BeforeFirst(wxT(')')).MakeLower());
    return !m_CfgMan->Exists(cSets + m_ActiveSet + _T('/') + member + _T("/base"));
}

Why there is a ! before m_CfgMan->Exists() ?
When debug into m_CfgMan->Exists(), I see that it do return true, but GetUserVariableManager().Exists() is false.

Another question is: Is user variable different from global variable? Any one can explain? Thanks.