Fix memory leak in GUIHyperText (#9489)

master
DS 2020-03-10 20:32:38 +01:00 committed by GitHub
parent 7a7bfdca7c
commit b42493fb4c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 6 deletions

View File

@ -1654,8 +1654,9 @@ void GUIFormSpecMenu::parseHyperText(parserData *data, const std::string &elemen
); );
spec.ftype = f_Unknown; spec.ftype = f_Unknown;
new GUIHyperText( GUIHyperText *e = new GUIHyperText(spec.flabel.c_str(), Environment, this,
spec.flabel.c_str(), Environment, this, spec.fid, rect, m_client, m_tsrc); spec.fid, rect, m_client, m_tsrc);
e->drop();
m_fields.push_back(spec); m_fields.push_back(spec);
} }

View File

@ -109,7 +109,6 @@ ParsedText::ParsedText(const wchar_t *text)
m_root_tag.style["color"] = "#EEEEEE"; m_root_tag.style["color"] = "#EEEEEE";
m_root_tag.style["hovercolor"] = m_root_tag.style["color"]; m_root_tag.style["hovercolor"] = m_root_tag.style["color"];
m_tags.push_back(&m_root_tag);
m_active_tags.push_front(&m_root_tag); m_active_tags.push_front(&m_root_tag);
m_style = m_root_tag.style; m_style = m_root_tag.style;
@ -174,7 +173,7 @@ ParsedText::ParsedText(const wchar_t *text)
ParsedText::~ParsedText() ParsedText::~ParsedText()
{ {
for (auto &tag : m_tags) for (auto &tag : m_not_root_tags)
delete tag; delete tag;
} }
@ -289,7 +288,7 @@ ParsedText::Tag *ParsedText::newTag(const std::string &name, const AttrsList &at
Tag *newtag = new Tag(); Tag *newtag = new Tag();
newtag->name = name; newtag->name = name;
newtag->attrs = attrs; newtag->attrs = attrs;
m_tags.push_back(newtag); m_not_root_tags.push_back(newtag);
return newtag; return newtag;
} }
@ -1012,6 +1011,7 @@ GUIHyperText::GUIHyperText(const wchar_t *text, IGUIEnvironment *environment,
GUIHyperText::~GUIHyperText() GUIHyperText::~GUIHyperText()
{ {
m_vscrollbar->remove(); m_vscrollbar->remove();
m_vscrollbar->drop();
} }
ParsedText::Element *GUIHyperText::getElementAt(s32 X, s32 Y) ParsedText::Element *GUIHyperText::getElementAt(s32 X, s32 Y)

View File

@ -153,7 +153,7 @@ protected:
std::unordered_map<std::string, StyleList> m_elementtags; std::unordered_map<std::string, StyleList> m_elementtags;
std::unordered_map<std::string, StyleList> m_paragraphtags; std::unordered_map<std::string, StyleList> m_paragraphtags;
std::vector<Tag *> m_tags; std::vector<Tag *> m_not_root_tags;
std::list<Tag *> m_active_tags; std::list<Tag *> m_active_tags;
// Current values // Current values