]> granicus.if.org Git - graphviz/commitdiff
visio plugin: manage _line member of Graphic as a value instead of pointer
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Thu, 8 Apr 2021 00:10:31 +0000 (17:10 -0700)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Sat, 17 Apr 2021 23:07:40 +0000 (16:07 -0700)
This member is never set to NULL and the Line class is not involved in any
inheritance hierarchy. So there is no need to heap-allocate it or pass it around
by pointer.

plugin/visio/VisioGraphic.cpp
plugin/visio/VisioGraphic.h

index d20c95ce1601b7ab0536668344b87f7f56e7517a..f3d794aebfdc267d730896af4d3a30412918d5e5 100644 (file)
@@ -413,7 +413,7 @@ namespace Visio
                                break;
                }
                return new Graphic(
-                       new Line(
+                       Line(
                                job->obj->penwidth,
                                job->obj->pencolor.u.rgba[0],
                                job->obj->pencolor.u.rgba[1],
@@ -443,7 +443,7 @@ namespace Visio
                                break;
                }
                return new Graphic(
-                       new Line(
+                       Line(
                                job->obj->penwidth,
                                job->obj->pencolor.u.rgba[0],
                                job->obj->pencolor.u.rgba[1],
@@ -478,7 +478,7 @@ namespace Visio
                                break;
                }
                return new Graphic(
-                       new Line(
+                       Line(
                                job->obj->penwidth,
                                job->obj->pencolor.u.rgba[0],
                                job->obj->pencolor.u.rgba[1],
@@ -510,7 +510,7 @@ namespace Visio
                                break;
                }
                return new Graphic(
-                       new Line(
+                       Line(
                                job->obj->penwidth,
                                job->obj->pencolor.u.rgba[0],
                                job->obj->pencolor.u.rgba[1],
@@ -522,7 +522,7 @@ namespace Visio
                                n));
        }
        
-       Graphic::Graphic(Line* line, Fill* fill, Geom* geom):
+       Graphic::Graphic(const Line &line, Fill* fill, Geom* geom):
                _line(line),
                _fill(fill),
                _geom(geom)
@@ -531,8 +531,6 @@ namespace Visio
        
        Graphic::~Graphic()
        {
-               if (_line)
-                       delete _line;
                if (_fill)
                        delete _fill;
                if (_geom)
@@ -551,8 +549,7 @@ namespace Visio
                
        void Graphic::Print(GVJ_t* job, pointf first, pointf last, bool allowCurves) const
        {
-               if (_line)
-                       _line->Print(job);
+               _line.Print(job);
                if (_fill)
                        _fill->Print(job);
                if (_geom)
index b83a8227efbf992d9ee9927be31f9e28033c5bb6..1e0313508c693070815300fc523245060b4dc357 100644 (file)
@@ -162,9 +162,9 @@ namespace Visio
                void Print(GVJ_t* job, pointf first, pointf last, bool allowCurves) const;
                
        private:
-               Graphic(Line* line, Fill* fill, Geom* geom);
+               Graphic(const Line &line, Fill* fill, Geom* geom);
                
-               Line* _line;
+               Line _line;
                Fill* _fill;
                Geom* _geom;
        };