This lets us clean up some manual handling of these and stop worrying about
memory management. Note that Visio::Render::ClearGraphicsAndTexts touched in
this commit is effectively a hand written destructor for this class. Presumably
it was implemented in a time before destructors were standardized. We can likely
move the other collections affected here to using smart pointers too and remove
this function entirely eventually.
void Render::ClearGraphicsAndTexts()
{
- /* clear graphics */
- for (Graphics::iterator nextGraphic = _graphics.begin(), lastGraphic = _graphics.end(); nextGraphic != lastGraphic; ++nextGraphic)
- delete *nextGraphic;
_graphics.clear();
/* clear texts */
{
if (_inComponent)
/* if in component, accumulate for end node/edge */
- _graphics.push_back(graphic);
+ _graphics.emplace_back(graphic);
else
/* if outside, output immediately */
PrintOuterShape(job, *graphic);
#define VISIORENDER_H
#include <map>
+#include <memory>
#include <vector>
#include <common/types.h>
namespace Visio
{
typedef std::map<Agnode_t*, unsigned int> NodeIds;
- typedef std::vector<Graphic*> Graphics;
+ typedef std::vector<std::unique_ptr<Graphic>> Graphics;
typedef std::vector<const Text*> Texts;
typedef std::vector<const Hyperlink*> Hyperlinks;