Bug #3639 » 0001-Fix-two-leaks-with-internal-stylesheets-in-Render.patch
src/Wt/Render/Block.C | ||
---|---|---|
126 | 126 |
for (unsigned int i = 0; i < children_.size(); ++i) { |
127 | 127 |
if (children_[i]->type_ == DomElement_STYLE) { |
128 | 128 |
ss << Render::Utils::nodeValueToString(children_[i]->node_); |
129 |
delete children_[i]; |
|
129 | 130 |
children_.erase(children_.begin() + i); |
130 | 131 |
--i; |
131 | 132 |
} else |
src/Wt/Render/WTextRenderer.C | ||
---|---|---|
37 | 37 |
{ |
38 | 38 |
public: |
39 | 39 |
CombinedStyleSheet() { } |
40 |
virtual ~CombinedStyleSheet() { } |
|
40 |
virtual ~CombinedStyleSheet() { |
|
41 |
for (unsigned i = 0; i < sheets_.size(); ++i) |
|
42 |
if (!sheets_not_owned_.count(sheets_[i])) |
|
43 |
delete sheets_[i]; |
|
44 |
} |
|
41 | 45 | |
42 |
void use(StyleSheet *sh) { |
|
46 |
void use(StyleSheet *sh, bool noFree = false) {
|
|
43 | 47 |
sheets_.push_back(sh); |
48 |
if (noFree) |
|
49 |
sheets_not_owned_.insert(sh); |
|
44 | 50 |
} |
45 | 51 | |
46 | 52 |
virtual unsigned int rulesetSize() const { |
... | ... | |
62 | 68 | |
63 | 69 |
private: |
64 | 70 |
std::vector<StyleSheet *> sheets_; |
71 |
std::set<StyleSheet *> sheets_not_owned_; |
|
65 | 72 |
}; |
66 | 73 | |
67 | 74 |
WTextRenderer::Node::Node(Block& block, LayoutBox& lb, |
... | ... | |
180 | 187 | |
181 | 188 |
CombinedStyleSheet styles; |
182 | 189 |
if (styleSheet_) |
183 |
styles.use(styleSheet_); |
|
190 |
styles.use(styleSheet_, true);
|
|
184 | 191 | |
185 | 192 |
WStringStream ss; |
186 | 193 |
docBlock.collectStyles(ss); |
test/paintdevice/WRasterTest.C | ||
---|---|---|
3 | 3 |
* |
4 | 4 |
* See the LICENSE file for terms of use. |
5 | 5 |
*/ |
6 | ||
7 |
#include <Wt/WConfig.h> |
|
8 | ||
6 | 9 |
#ifdef WT_HAS_WRASTERIMAGE |
7 | 10 | |
8 | 11 |
#include <boost/test/unit_test.hpp> |
... | ... | |
85 | 88 |
rasterImage.write(f); |
86 | 89 |
} |
87 | 90 | |
91 |
BOOST_AUTO_TEST_CASE( raster_test_text_embedded_stylesheet ) |
|
92 |
{ |
|
93 |
Wt::Test::WTestEnvironment environment; |
|
94 |
Wt::WApplication app(environment); |
|
95 | ||
96 |
Wt::WRasterImage rasterImage("png", 357, 193); |
|
97 |
{ |
|
98 |
Wt::WPainter p(&rasterImage); |
|
99 |
std::string text = |
|
100 |
"<style>" |
|
101 |
"table {width:357px;}" |
|
102 |
"td {padding: 0px; height: 193px; color: #f71175;" |
|
103 |
"text-align: left; vertical-align: top; font-family: Arial;" |
|
104 |
"font-size: 60.0pt; font-weight: normal;}" |
|
105 |
"</style>" |
|
106 |
"<table><tr><td>xxx</td></tr></table>"; |
|
107 |
MultiLineTextRenderer renderer(p, WRectF(0, 0, 357, 193)); |
|
108 |
renderer.render(text); |
|
109 |
} |
|
110 | ||
111 |
std::ofstream f("text_render_image_2.png"); |
|
112 |
rasterImage.write(f); |
|
113 |
} |
|
114 | ||
88 | 115 |
BOOST_AUTO_TEST_CASE( raster_test_dataUriImage ) |
89 | 116 |
{ |
90 | 117 |
Wt::Test::WTestEnvironment environment; |
91 |
- |