Plumb some ownership around.
This commit is contained in:
15
src/html.cc
15
src/html.cc
@ -2346,7 +2346,7 @@ static void
|
||||
DilloUrl* url;
|
||||
const char *attrbuf;
|
||||
int link = -1;
|
||||
Shape *shape = NULL;
|
||||
std::unique_ptr< Shape > shape;
|
||||
|
||||
if (!(html->InFlags & IN_MAP)) {
|
||||
BUG_MSG("<area> not inside <map>.");
|
||||
@ -2376,7 +2376,7 @@ static void
|
||||
if (coords->size() != 4)
|
||||
BUG_MSG("<area> rectangle must have four coordinate values.");
|
||||
if (coords->size() >= 4)
|
||||
shape = new Rectangle(coords->get(0),
|
||||
shape = std::make_unique< Rectangle >(coords->get(0),
|
||||
coords->get(1),
|
||||
coords->get(2) - coords->get(0),
|
||||
coords->get(3) - coords->get(1));
|
||||
@ -2384,21 +2384,22 @@ static void
|
||||
if (coords->size() != 3)
|
||||
BUG_MSG("<area> circle must have three coordinate values.");
|
||||
if (coords->size() >= 3)
|
||||
shape = new Circle(coords->get(0), coords->get(1),
|
||||
shape = std::make_unique< Circle >(coords->get(0), coords->get(1),
|
||||
coords->get(2));
|
||||
} else if (type == POLYGON) {
|
||||
Polygon *poly;
|
||||
std::unique_ptr< Polygon > poly;
|
||||
int i;
|
||||
if (coords->size() % 2)
|
||||
BUG_MSG("<area> polygon with odd number of coordinates.");
|
||||
shape = poly = new Polygon();
|
||||
poly = std::make_unique< Polygon >();
|
||||
for (i = 0; i < (coords->size() / 2); i++)
|
||||
poly->addPoint(coords->get(2*i), coords->get(2*i + 1));
|
||||
shape= std::move( poly );
|
||||
}
|
||||
delete(coords);
|
||||
}
|
||||
}
|
||||
if (shape != NULL || type == BACKGROUND) {
|
||||
if (shape != nullptr || type == BACKGROUND) {
|
||||
if ((attrbuf = a_Html_get_attr(html, tag, tagsize, "href"))) {
|
||||
url = a_Html_url_new(html, attrbuf, NULL, 0).release();
|
||||
dReturn_if_fail ( url != NULL );
|
||||
@ -2408,7 +2409,7 @@ static void
|
||||
if (type == BACKGROUND)
|
||||
html->maps.setCurrentMapDefaultLink(link);
|
||||
else
|
||||
html->maps.addShapeToCurrentMap(shape, link);
|
||||
html->maps.addShapeToCurrentMap(std::move( shape ), link);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user