Removed some of the "normal" pointers and replaced them by smart pointer to prevent memory problems

This commit is contained in:
Tats
2013-12-01 00:16:33 -05:00
parent 0015e237c9
commit 8d0473410b
2 changed files with 10 additions and 10 deletions
+6 -6
View File
@@ -176,11 +176,11 @@ void MainWindow::addQuad()
Q_CHECK_PTR(texture);
// Create input and output quads.
Quad* outputQuad = Util::createQuadForTexture(texture.get(), sourceCanvas->width(), sourceCanvas->height());
Quad* inputQuad = Util::createQuadForTexture(texture.get(), sourceCanvas->width(), sourceCanvas->height());
Shape::ptr outputQuad = Shape::ptr(Util::createQuadForTexture(texture.get(), sourceCanvas->width(), sourceCanvas->height()));
Shape::ptr inputQuad = Shape::ptr(Util::createQuadForTexture(texture.get(), sourceCanvas->width(), sourceCanvas->height()));
// Create texture mapping.
int mappingId = mappingManager->addMapping(Mapping::ptr(new TextureMapping(paint.get(), outputQuad, inputQuad)));
int mappingId = mappingManager->addMapping(Mapping::ptr(new TextureMapping(paint, outputQuad, inputQuad)));
addMappingItem(mappingId);
}
@@ -197,11 +197,11 @@ void MainWindow::addTriangle()
Q_CHECK_PTR(texture);
// Create input and output quads.
Triangle* outputTriangle = Util::createTriangleForTexture(texture.get(), sourceCanvas->width(), sourceCanvas->height());
Triangle* inputTriangle = Util::createTriangleForTexture(texture.get(), sourceCanvas->width(), sourceCanvas->height());
Shape::ptr outputTriangle = Shape::ptr(Util::createTriangleForTexture(texture.get(), sourceCanvas->width(), sourceCanvas->height()));
Shape::ptr inputTriangle = Shape::ptr(Util::createTriangleForTexture(texture.get(), sourceCanvas->width(), sourceCanvas->height()));
// Create texture mapping.
int mappingId = mappingManager->addMapping(Mapping::ptr(new TextureMapping(paint.get(), inputTriangle, outputTriangle)));
int mappingId = mappingManager->addMapping(Mapping::ptr(new TextureMapping(paint, inputTriangle, outputTriangle)));
addMappingItem(mappingId);
}
+4 -4
View File
@@ -42,7 +42,7 @@ protected:
public:
typedef std::tr1::shared_ptr<Mapping> ptr;
Mapping(Paint* paint, Shape* shape)
Mapping(Paint::ptr paint, Shape::ptr shape)
: _paint(paint), _shape(shape)
{}
virtual ~Mapping() {}
@@ -67,9 +67,9 @@ private:
Shape::ptr _inputShape;
public:
TextureMapping(Paint* paint,
Shape* shape,
Shape* inputShape)
TextureMapping(Paint::ptr paint,
Shape::ptr shape,
Shape::ptr inputShape)
: Mapping(paint, shape),
_inputShape(inputShape)
{}