summaryrefslogtreecommitdiff
path: root/libs
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2024-10-29 19:00:23 +0300
committerGeorge Hazan <george.hazan@gmail.com>2024-10-29 19:00:23 +0300
commit6dfe0158622a7133ac3a8b149eb0280c86673105 (patch)
tree3b2eb96e0fe1bb0427befba912e8a5f31b71ff0f /libs
parent4ff0acc120ea0334dc36c2f11adab478c92803a0 (diff)
fixes #4624 (GDI leaks in NewStory)
Diffstat (limited to 'libs')
-rw-r--r--libs/litehtml/include/litehtml/document.h1
-rw-r--r--libs/litehtml/include/litehtml/document_container.h2
-rw-r--r--libs/litehtml/src/document.cpp15
3 files changed, 6 insertions, 12 deletions
diff --git a/libs/litehtml/include/litehtml/document.h b/libs/litehtml/include/litehtml/document.h
index 3f94565655..7119636ffe 100644
--- a/libs/litehtml/include/litehtml/document.h
+++ b/libs/litehtml/include/litehtml/document.h
@@ -50,7 +50,6 @@ namespace litehtml
std::shared_ptr<element> m_root;
std::shared_ptr<render_item> m_root_render;
document_container* m_container;
- fonts_map m_fonts;
css_text::vector m_css;
litehtml::css m_styles;
litehtml::web_color m_def_color;
diff --git a/libs/litehtml/include/litehtml/document_container.h b/libs/litehtml/include/litehtml/document_container.h
index 395c6cd1a7..95efe1eb6b 100644
--- a/libs/litehtml/include/litehtml/document_container.h
+++ b/libs/litehtml/include/litehtml/document_container.h
@@ -33,6 +33,8 @@ namespace litehtml
class document_container
{
public:
+ fonts_map m_fonts;
+
virtual litehtml::uint_ptr create_font(const char* faceName, int size, int weight, litehtml::font_style italic, unsigned int decoration, litehtml::font_metrics* fm) = 0;
virtual void delete_font(litehtml::uint_ptr hFont) = 0;
virtual int text_width(const char* text, litehtml::uint_ptr hFont) = 0;
diff --git a/libs/litehtml/src/document.cpp b/libs/litehtml/src/document.cpp
index 471f9204c7..13bfe0e991 100644
--- a/libs/litehtml/src/document.cpp
+++ b/libs/litehtml/src/document.cpp
@@ -37,13 +37,6 @@ document::document(document_container* container)
document::~document()
{
m_over_element = nullptr;
- if(m_container)
- {
- for(auto& font : m_fonts)
- {
- m_container->delete_font(font.second.font);
- }
- }
}
document::ptr document::createFromString(
@@ -463,7 +456,7 @@ uint_ptr document::add_font( const char* name, int size, const char* weight, con
key += ":";
key += decoration;
- if(m_fonts.find(key) == m_fonts.end())
+ if(m_container->m_fonts.find(key) == m_container->m_fonts.end())
{
font_style fs = (font_style) value_index(style, font_style_strings, font_style_normal);
int fw = value_index(weight, font_weight_strings, -1);
@@ -517,7 +510,7 @@ uint_ptr document::add_font( const char* name, int size, const char* weight, con
font_item fi= {0, {}};
fi.font = m_container->create_font(name, size, fw, fs, decor, &fi.metrics);
- m_fonts[key] = fi;
+ m_container->m_fonts[key] = fi;
ret = fi.font;
if(fm)
{
@@ -551,9 +544,9 @@ uint_ptr document::get_font( const char* name, int size, const char* weight, con
key += ":";
key += decoration;
- auto el = m_fonts.find(key);
+ auto el = m_container->m_fonts.find(key);
- if(el != m_fonts.end())
+ if(el != m_container->m_fonts.end())
{
if(fm)
{