Commit 9ba032ea authored by Cyril Deguet's avatar Cyril Deguet

* var_manager.cpp: explicit object destruction order to avoid access

to an already destroyed map ! (and a crash with MSVC runtime...)
parent 9eb39c51
......@@ -26,8 +26,10 @@
VarManager::VarManager( intf_thread_t *pIntf ): SkinObject( pIntf ),
m_tooltipText( pIntf ), m_helpText( pIntf, false )
m_pTooltipText( NULL ), m_pHelpText( NULL )
{
m_pTooltipText = new VarText( pIntf );
m_pHelpText = new VarText( pIntf, false );
}
......@@ -45,6 +47,12 @@ VarManager::~VarManager()
{
m_anonVarList.pop_back();
}
delete m_pTooltipText;
// Warning! the help text must be the last variable to be deleted,
// because VarText destructor references it (FIXME: find a cleaner way?)
delete m_pHelpText;
}
......
......@@ -52,16 +52,16 @@ class VarManager: public SkinObject
Variable *getVar( const string &rName, const string &rType );
/// Get the tooltip text variable
VarText &getTooltipText() { return m_tooltipText; }
VarText &getTooltipText() { return *m_pTooltipText; }
/// Get the help text variable
VarText &getHelpText() { return m_helpText; }
VarText &getHelpText() { return *m_pHelpText; }
private:
/// Tooltip text
VarText m_tooltipText;
VarText *m_pTooltipText;
/// Help text
VarText m_helpText;
VarText *m_pHelpText;
/// Map of named registered variables
map<string, VariablePtr> m_varMap;
/// List of named registed variables
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment