fixed memory leak in RestoreState
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@48431 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -132,8 +132,13 @@ void wxHtmlParser::DoneParser()
|
|||||||
void wxHtmlParser::SetSource(const wxString& src)
|
void wxHtmlParser::SetSource(const wxString& src)
|
||||||
{
|
{
|
||||||
DestroyDOMTree();
|
DestroyDOMTree();
|
||||||
// NB: this is allocated on heap because wxHtmlTag keeps a pointer to
|
// NB: This is allocated on heap because wxHtmlTag uses iterators and
|
||||||
// this string if WXWIN_COMPATIBILITY_2_8
|
// making a copy of m_Source string in SetSourceAndSaveState() and
|
||||||
|
// RestoreState() would invalidate them (because wxString::m_impl's
|
||||||
|
// memory would change completely twice and iterators use pointers
|
||||||
|
// into it). So instead, we keep the string object intact and only
|
||||||
|
// store/restore pointer to it, for which we need it to be allocated
|
||||||
|
// on the heap.
|
||||||
delete m_Source;
|
delete m_Source;
|
||||||
m_Source = new wxString(src);
|
m_Source = new wxString(src);
|
||||||
CreateDOMTree();
|
CreateDOMTree();
|
||||||
@@ -411,6 +416,7 @@ bool wxHtmlParser::RestoreState()
|
|||||||
if (!m_SavedStates) return false;
|
if (!m_SavedStates) return false;
|
||||||
|
|
||||||
DestroyDOMTree();
|
DestroyDOMTree();
|
||||||
|
delete m_Source;
|
||||||
|
|
||||||
wxHtmlParserState *s = m_SavedStates;
|
wxHtmlParserState *s = m_SavedStates;
|
||||||
m_SavedStates = s->m_nextState;
|
m_SavedStates = s->m_nextState;
|
||||||
|
Reference in New Issue
Block a user