Project

General

Profile

Bug #3639 » 0001-Fix-two-leaks-with-internal-stylesheets-in-Render.patch

Bruce Toll, 10/28/2014 01:55 AM

View differences:

src/Wt/Render/Block.C
for (unsigned int i = 0; i < children_.size(); ++i) {
if (children_[i]->type_ == DomElement_STYLE) {
ss << Render::Utils::nodeValueToString(children_[i]->node_);
delete children_[i];
children_.erase(children_.begin() + i);
--i;
} else
src/Wt/Render/WTextRenderer.C
{
public:
CombinedStyleSheet() { }
virtual ~CombinedStyleSheet() { }
virtual ~CombinedStyleSheet() {
for (unsigned i = 0; i < sheets_.size(); ++i)
if (!sheets_not_owned_.count(sheets_[i]))
delete sheets_[i];
}
void use(StyleSheet *sh) {
void use(StyleSheet *sh, bool noFree = false) {
sheets_.push_back(sh);
if (noFree)
sheets_not_owned_.insert(sh);
}
virtual unsigned int rulesetSize() const {
......
private:
std::vector<StyleSheet *> sheets_;
std::set<StyleSheet *> sheets_not_owned_;
};
WTextRenderer::Node::Node(Block& block, LayoutBox& lb,
......
CombinedStyleSheet styles;
if (styleSheet_)
styles.use(styleSheet_);
styles.use(styleSheet_, true);
WStringStream ss;
docBlock.collectStyles(ss);
test/paintdevice/WRasterTest.C
*
* See the LICENSE file for terms of use.
*/
#include <Wt/WConfig.h>
#ifdef WT_HAS_WRASTERIMAGE
#include <boost/test/unit_test.hpp>
......
rasterImage.write(f);
}
BOOST_AUTO_TEST_CASE( raster_test_text_embedded_stylesheet )
{
Wt::Test::WTestEnvironment environment;
Wt::WApplication app(environment);
Wt::WRasterImage rasterImage("png", 357, 193);
{
Wt::WPainter p(&rasterImage);
std::string text =
"<style>"
"table {width:357px;}"
"td {padding: 0px; height: 193px; color: #f71175;"
"text-align: left; vertical-align: top; font-family: Arial;"
"font-size: 60.0pt; font-weight: normal;}"
"</style>"
"<table><tr><td>xxx</td></tr></table>";
MultiLineTextRenderer renderer(p, WRectF(0, 0, 357, 193));
renderer.render(text);
}
std::ofstream f("text_render_image_2.png");
rasterImage.write(f);
}
BOOST_AUTO_TEST_CASE( raster_test_dataUriImage )
{
Wt::Test::WTestEnvironment environment;
(1-1/2)