mirror of
https://github.com/aseprite/aseprite.git
synced 2024-10-03 21:46:20 +00:00
Delete all css::Styles when the skin::StyleSheet is destroyed
This commit is contained in:
parent
456bdaa20a
commit
9af8440ba6
@ -586,10 +586,10 @@ void SkinTheme::onRegenerate()
|
||||
const css::Style* base = NULL;
|
||||
|
||||
if (base_id)
|
||||
base = m_stylesheet.sheet().getStyle(base_id);
|
||||
base = m_stylesheet.getCssStyle(base_id);
|
||||
|
||||
css::Style* style = new css::Style(style_id, base);
|
||||
m_stylesheet.sheet().addStyle(style);
|
||||
m_stylesheet.addCssStyle(style);
|
||||
|
||||
TiXmlElement* xmlRule = xmlStyle->FirstChildElement();
|
||||
while (xmlRule) {
|
||||
|
@ -60,15 +60,28 @@ StyleSheet::StyleSheet()
|
||||
|
||||
StyleSheet::~StyleSheet()
|
||||
{
|
||||
destroyAllStyles();
|
||||
delete m_sheet;
|
||||
}
|
||||
|
||||
void StyleSheet::destroyAllStyles()
|
||||
{
|
||||
// Destroy skin::Styles
|
||||
for (StyleMap::iterator it = m_styles.begin(), end = m_styles.end();
|
||||
it != end; ++it)
|
||||
delete it->second;
|
||||
|
||||
// Destroy css::Styles
|
||||
for (std::vector<css::Style*>::iterator it = m_cssStyles.begin(), end = m_cssStyles.end();
|
||||
it != end; ++it)
|
||||
delete *it;
|
||||
|
||||
delete m_sheet;
|
||||
}
|
||||
|
||||
void StyleSheet::addCssStyle(css::Style* style)
|
||||
{
|
||||
m_sheet->addStyle(style);
|
||||
m_cssStyles.push_back(style);
|
||||
}
|
||||
|
||||
const css::Style* StyleSheet::getCssStyle(const std::string& id)
|
||||
{
|
||||
return m_sheet->getStyle(id);
|
||||
}
|
||||
|
||||
Style* StyleSheet::getStyle(const std::string& id)
|
||||
|
@ -32,6 +32,7 @@ class TiXmlElement;
|
||||
|
||||
namespace css {
|
||||
class Sheet;
|
||||
class Style;
|
||||
class Value;
|
||||
}
|
||||
|
||||
@ -56,7 +57,8 @@ namespace app {
|
||||
static css::Rule& paddingRightRule() { return m_paddingRightRule; }
|
||||
static css::Rule& paddingBottomRule() { return m_paddingBottomRule; }
|
||||
|
||||
css::Sheet& sheet() { return *m_sheet; }
|
||||
void addCssStyle(css::Style* style);
|
||||
const css::Style* getCssStyle(const std::string& id);
|
||||
|
||||
Style* getStyle(const std::string& id);
|
||||
|
||||
@ -66,8 +68,6 @@ namespace app {
|
||||
private:
|
||||
typedef std::map<std::string, Style*> StyleMap;
|
||||
|
||||
void destroyAllStyles();
|
||||
|
||||
static css::Rule m_backgroundColorRule;
|
||||
static css::Rule m_backgroundPartRule;
|
||||
static css::Rule m_iconAlignRule;
|
||||
@ -80,6 +80,7 @@ namespace app {
|
||||
static css::Rule m_paddingBottomRule;
|
||||
|
||||
css::Sheet* m_sheet;
|
||||
std::vector<css::Style*> m_cssStyles;
|
||||
StyleMap m_styles;
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user