diff options
author | Andrei Karas <akaras@inbox.ru> | 2017-02-19 05:47:59 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2017-02-19 23:04:53 +0300 |
commit | 80ba4766d8ce9861f6d026e791abc741e3fed0f4 (patch) | |
tree | 02d509ecd3ae384fba0b8d44a60c71033e3d31d3 /src/gui | |
parent | 4526407e2001244a03674e57db8a6807cbbbe2b0 (diff) | |
download | plus-80ba4766d8ce9861f6d026e791abc741e3fed0f4.tar.gz plus-80ba4766d8ce9861f6d026e791abc741e3fed0f4.tar.bz2 plus-80ba4766d8ce9861f6d026e791abc741e3fed0f4.tar.xz plus-80ba4766d8ce9861f6d026e791abc741e3fed0f4.zip |
Fix some memory leaks and add duplicate item fields check.
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/theme.cpp | 55 | ||||
-rw-r--r-- | src/gui/widgets/tabs/setup_players.cpp | 1 |
2 files changed, 35 insertions, 21 deletions
diff --git a/src/gui/theme.cpp b/src/gui/theme.cpp index 064bec44f..9fa1b59ec 100644 --- a/src/gui/theme.cpp +++ b/src/gui/theme.cpp @@ -1178,16 +1178,28 @@ ImageSet *Theme::getImageSetFromThemeXml(const std::string &name, } #define readValue(name) \ - info->name = reinterpret_cast<const char*>(\ - XmlNodeGetContent(infoNode)) + { \ + tmpData = reinterpret_cast<char*>( \ + XmlNodeGetContent(infoNode)); \ + info->name = tmpData; \ + XmlFree(tmpData); \ + } #define readIntValue(name) \ - info->name = atoi(reinterpret_cast<const char*>(\ - XmlNodeGetContent(infoNode))) + { \ + tmpData = reinterpret_cast<char*>( \ + XmlNodeGetContent(infoNode)); \ + info->name = atoi(tmpData); \ + XmlFree(tmpData); \ + } #define readFloatValue(name) \ - info->name = static_cast<float>(atof(reinterpret_cast<const char*>(\ - XmlNodeGetContent(infoNode)))) + { \ + tmpData = reinterpret_cast<char*>( \ + XmlNodeGetContent(infoNode)); \ + info->name = static_cast<float>(atof(tmpData)); \ + XmlFree(tmpData); \ + } ThemeInfo *Theme::loadInfo(const std::string &themeName) { @@ -1219,38 +1231,39 @@ ThemeInfo *Theme::loadInfo(const std::string &themeName) const std::string fontSize2("fontSize_" + mScreenDensity); const std::string npcfontSize2("npcfontSize_" + mScreenDensity); + char *tmpData = nullptr; for_each_xml_child_node(infoNode, rootNode) { if (xmlNameEqual(infoNode, "name")) - readValue(name); + readValue(name) else if (xmlNameEqual(infoNode, "copyright")) - readValue(copyright); + readValue(copyright) else if (xmlNameEqual(infoNode, "font")) - readValue(font); + readValue(font) else if (xmlNameEqual(infoNode, "boldFont")) - readValue(boldFont); + readValue(boldFont) else if (xmlNameEqual(infoNode, "particleFont")) - readValue(particleFont); + readValue(particleFont) else if (xmlNameEqual(infoNode, "helpFont")) - readValue(helpFont); + readValue(helpFont) else if (xmlNameEqual(infoNode, "secureFont")) - readValue(secureFont); + readValue(secureFont) else if (xmlNameEqual(infoNode, "npcFont")) - readValue(npcFont); + readValue(npcFont) else if (xmlNameEqual(infoNode, "japanFont")) - readValue(japanFont); + readValue(japanFont) else if (xmlNameEqual(infoNode, "chinaFont")) - readValue(chinaFont); + readValue(chinaFont) else if (xmlNameEqual(infoNode, "fontSize")) - readIntValue(fontSize); + readIntValue(fontSize) else if (xmlNameEqual(infoNode, "npcfontSize")) - readIntValue(npcfontSize); + readIntValue(npcfontSize) else if (xmlNameEqual(infoNode, "guialpha")) - readFloatValue(guiAlpha); + readFloatValue(guiAlpha) else if (xmlNameEqual(infoNode, fontSize2.c_str())) - readIntValue(fontSize); + readIntValue(fontSize) else if (xmlNameEqual(infoNode, npcfontSize2.c_str())) - readIntValue(npcfontSize); + readIntValue(npcfontSize) } doc->decRef(); return info; diff --git a/src/gui/widgets/tabs/setup_players.cpp b/src/gui/widgets/tabs/setup_players.cpp index ae352d579..ca3506aa4 100644 --- a/src/gui/widgets/tabs/setup_players.cpp +++ b/src/gui/widgets/tabs/setup_players.cpp @@ -171,6 +171,7 @@ Setup_Players::Setup_Players(const Widget2 *const widget) : Setup_Players::~Setup_Players() { delete2(mBadgesList); + delete2(mVisibleNamesList); } void Setup_Players::externalUpdated() |