diff --git a/dw/image.cc b/dw/image.cc
index 6582c8f..2c4f632 100644
--- a/dw/image.cc
+++ b/dw/image.cc
@@ -31,8 +31,8 @@ namespace dw {
using namespace lout;
-void ImageMapsList::ImageMap::draw (core::View *view,core::style::Style *style,
- int x, int y)
+void
+ImageMapsList::ImageMap::draw( core::View *view, core::style::Style *style, int x, int y )
{
for( auto &shapeAndLink: shapesAndLinks )
{
@@ -40,9 +40,11 @@ void ImageMapsList::ImageMap::draw (core::View *view,core::style::Style *style,
}
}
-void ImageMapsList::ImageMap::add (core::Shape *shape, int link) {
+void
+ImageMapsList::ImageMap::add( std::unique_ptr< core::Shape > shape, int link )
+{
auto shapeAndLink = std::make_unique< ShapeAndLink >();
- shapeAndLink->shape = shape;
+ shapeAndLink->shape = std::move( shape );
shapeAndLink->link = link;
shapesAndLinks.push_back( std::move( shapeAndLink ) );
}
@@ -93,9 +95,10 @@ void ImageMapsList::startNewMap (object::Object *key)
* "shape" is owned by the image map list, so a copy should be passed, when
* necessary.
*/
-void ImageMapsList::addShapeToCurrentMap (core::Shape *shape, int link)
+void
+ImageMapsList::addShapeToCurrentMap( std::unique_ptr< core::Shape > shape, const int link )
{
- currentMap->add (shape, link);
+ currentMap->add( std::move( shape ), link );
}
/**
diff --git a/dw/image.hh b/dw/image.hh
index e236703..fab660b 100644
--- a/dw/image.hh
+++ b/dw/image.hh
@@ -27,10 +27,8 @@ private:
private:
class ShapeAndLink: public lout::object::Object {
public:
- core::Shape *shape;
+ std::unique_ptr< core::Shape > shape;
int link;
-
- ~ShapeAndLink () { if (shape) delete shape; };
};
std::list< std::unique_ptr< ShapeAndLink > > shapesAndLinks;
@@ -38,7 +36,7 @@ private:
public:
void draw (core::View *view, core::style::Style *style, int x, int y);
- void add (core::Shape *shape, int link);
+ void add (std::unique_ptr< core::Shape > shape, int link);
void setDefaultLink (int link) { defaultLink = link; };
int link (int x, int y);
};
@@ -52,7 +50,7 @@ public:
~ImageMapsList ();
void startNewMap (lout::object::Object *key);
- void addShapeToCurrentMap (core::Shape *shape, int link);
+ void addShapeToCurrentMap( std::unique_ptr< core::Shape > shape, int link );
void setCurrentMapDefaultLink (int link);
void drawMap(lout::object::Object *key, core::View *view,
core::style::Style *style, int x, int y);
diff --git a/src/html.cc b/src/html.cc
index 71a3296..1e79358 100644
--- a/src/html.cc
+++ b/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(" not inside