+ // NB: This is allocated on heap because wxHtmlTag uses iterators and
+ // 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;
+ m_Source = new wxString(src);