summaryrefslogtreecommitdiffstats
path: root/src/ui
diff options
context:
space:
mode:
authorMarc Jeanmougin <marc@jeanmougin.fr>2019-10-04 16:26:34 +0000
committerMarc Jeanmougin <marc@jeanmougin.fr>2019-10-05 10:35:21 +0000
commit95e00bdf7075329277cac97a6fd0a929c9a8e453 (patch)
treeff4521ff8f759eec5aac329efbf00bbca68f0d70 /src/ui
parentFix segfault with bad SVG file. (diff)
downloadinkscape-95e00bdf7075329277cac97a6fd0a929c9a8e453.tar.gz
inkscape-95e00bdf7075329277cac97a6fd0a929c9a8e453.zip
Fix some memory leaks found by scan-build
Diffstat (limited to 'src/ui')
-rw-r--r--src/ui/dialog/paint-servers.cpp2
-rw-r--r--src/ui/dialog/template-load-tab.cpp1
-rw-r--r--src/ui/tool/path-manipulator.cpp4
-rw-r--r--src/ui/tools/pen-tool.cpp41
4 files changed, 24 insertions, 24 deletions
diff --git a/src/ui/dialog/paint-servers.cpp b/src/ui/dialog/paint-servers.cpp
index baabe271e..b34eeb67a 100644
--- a/src/ui/dialog/paint-servers.cpp
+++ b/src/ui/dialog/paint-servers.cpp
@@ -351,7 +351,7 @@ void PaintServersDialog::load_document(SPDocument *document)
void PaintServersDialog::load_current_document(SPObject * /*object*/, guint /*flags*/)
{
- PaintServersColumns *columns = getColumns();
+ std::unique_ptr<PaintServersColumns> columns(getColumns());
SPDocument *document = desktop->getDocument();
Glib::RefPtr<Gtk::ListStore> current = store[CURRENTDOC];
diff --git a/src/ui/dialog/template-load-tab.cpp b/src/ui/dialog/template-load-tab.cpp
index f290dcab7..6f5c65438 100644
--- a/src/ui/dialog/template-load-tab.cpp
+++ b/src/ui/dialog/template-load-tab.cpp
@@ -192,6 +192,7 @@ void TemplateLoadTab::_refreshTemplatesList()
}
}
if (_tlist_store->children().size() == 1) {
+ delete item_to_select;
item_to_select = new Gtk::TreeIter(_tlist_store->children().begin());
}
if (item_to_select) {
diff --git a/src/ui/tool/path-manipulator.cpp b/src/ui/tool/path-manipulator.cpp
index 1028731d2..9199ff4ed 100644
--- a/src/ui/tool/path-manipulator.cpp
+++ b/src/ui/tool/path-manipulator.cpp
@@ -1023,7 +1023,7 @@ NodeList::iterator PathManipulator::subdivideSegment(NodeList::iterator first, d
n->setType(NODE_SMOOTH, false);
} else {
Geom::D2< Geom::SBasis > sbasis_inside_nodes;
- SPCurve *line_inside_nodes = new SPCurve();
+ std::unique_ptr<SPCurve> line_inside_nodes(new SPCurve());
if(second->back()->isDegenerate()){
line_inside_nodes->moveto(n->position());
line_inside_nodes->lineto(second->position());
@@ -1311,7 +1311,7 @@ Geom::Point PathManipulator::_bsplineHandleReposition(Handle *h,double pos){
Geom::Point ret = h->position();
Node *n = h->parent();
Geom::D2< Geom::SBasis > sbasis_inside_nodes;
- SPCurve *line_inside_nodes = new SPCurve();
+ std::unique_ptr<SPCurve> line_inside_nodes(new SPCurve());
Node * next_node = nullptr;
next_node = n->nodeToward(h);
if(next_node && pos != NO_POWER){
diff --git a/src/ui/tools/pen-tool.cpp b/src/ui/tools/pen-tool.cpp
index 84297a0c1..9b25335d6 100644
--- a/src/ui/tools/pen-tool.cpp
+++ b/src/ui/tools/pen-tool.cpp
@@ -1470,7 +1470,7 @@ void PenTool::_bsplineSpiroMotion(guint const state){
using Geom::Y;
if(this->red_curve->is_unset()) return;
this->npoints = 5;
- SPCurve *tmp_curve = new SPCurve();
+ std::unique_ptr<SPCurve> tmp_curve(new SPCurve());
this->p[2] = this->p[3] + (1./3)*(this->p[0] - this->p[3]);
this->p[2] = Geom::Point(this->p[2][X] + HANDLE_CUBIC_GAP,this->p[2][Y] + HANDLE_CUBIC_GAP);
if (this->green_curve->is_unset() && !this->sa) {
@@ -1480,9 +1480,9 @@ void PenTool::_bsplineSpiroMotion(guint const state){
this->p[2] = this->p[3];
}
} else if (!this->green_curve->is_unset()){
- tmp_curve = this->green_curve->copy();
+ tmp_curve.reset(this->green_curve->copy());
} else {
- tmp_curve = this->sa_overwrited->copy();
+ tmp_curve.reset(this->sa_overwrited->copy());
}
if ((state & GDK_MOD1_MASK ) && previous != Geom::Point(0,0)) { //ALT drag
this->p[0] = this->p[0] + (this->p[3] - previous);
@@ -1591,16 +1591,16 @@ void PenTool::_bsplineSpiroEndAnchorOn()
using Geom::Y;
this->p[2] = this->p[3] + (1./3)*(this->p[0] - this->p[3]);
this->p[2] = Geom::Point(this->p[2][X] + HANDLE_CUBIC_GAP,this->p[2][Y] + HANDLE_CUBIC_GAP);
- SPCurve *tmp_curve;
- SPCurve *last_segment = new SPCurve();
+ std::unique_ptr<SPCurve> tmp_curve(new SPCurve());
+ std::unique_ptr<SPCurve> last_segment(new SPCurve());
Geom::Point point_c(0,0);
if( this->green_anchor && this->green_anchor->active ){
- tmp_curve = this->green_curve->create_reverse();
+ tmp_curve.reset(this->green_curve->create_reverse());
if(this->green_curve->get_segment_count()==0){
return;
}
} else if(this->sa){
- tmp_curve = this->sa_overwrited->copy()->create_reverse();
+ tmp_curve.reset(this->sa_overwrited->copy()->create_reverse());
}else{
return;
}
@@ -1619,14 +1619,14 @@ void PenTool::_bsplineSpiroEndAnchorOn()
last_segment->lineto(*tmp_curve ->last_point());
}
if( tmp_curve ->get_segment_count() == 1){
- tmp_curve = last_segment;
+ tmp_curve = std::move(last_segment);
}else{
//we eliminate the last segment
tmp_curve ->backspace();
//and we add it again with the recreation
- tmp_curve ->append_continuous(last_segment, 0.0625);
+ tmp_curve ->append_continuous(last_segment.get(), 0.0625);
}
- tmp_curve = tmp_curve ->create_reverse();
+ tmp_curve.reset(tmp_curve ->create_reverse());
if( this->green_anchor && this->green_anchor->active )
{
this->green_curve->reset();
@@ -1635,22 +1635,21 @@ void PenTool::_bsplineSpiroEndAnchorOn()
this->sa_overwrited->reset();
this->sa_overwrited = tmp_curve->copy();
}
- tmp_curve->unref();
}
void PenTool::_bsplineSpiroEndAnchorOff()
{
- SPCurve *tmp_curve;
- SPCurve *last_segment = new SPCurve();
+ std::unique_ptr<SPCurve> tmp_curve(new SPCurve());
+ std::unique_ptr<SPCurve> last_segment(new SPCurve());
this->p[2] = this->p[3];
if( this->green_anchor && this->green_anchor->active ){
- tmp_curve = this->green_curve->create_reverse();
+ tmp_curve.reset(this->green_curve->create_reverse());
if(this->green_curve->get_segment_count()==0){
return;
}
} else if(this->sa){
- tmp_curve = this->sa_overwrited->copy()->create_reverse();
+ tmp_curve.reset(this->sa_overwrited->copy()->create_reverse());
}else{
return;
}
@@ -1663,14 +1662,14 @@ void PenTool::_bsplineSpiroEndAnchorOff()
last_segment->lineto(*tmp_curve ->last_point());
}
if( tmp_curve ->get_segment_count() == 1){
- tmp_curve = last_segment;
+ tmp_curve = std::move(last_segment);
}else{
//we eliminate the last segment
tmp_curve ->backspace();
//and we add it again with the recreation
- tmp_curve ->append_continuous(last_segment, 0.0625);
+ tmp_curve ->append_continuous(last_segment.get(), 0.0625);
}
- tmp_curve = tmp_curve ->create_reverse();
+ tmp_curve.reset(tmp_curve ->create_reverse());
if( this->green_anchor && this->green_anchor->active )
{
@@ -1680,7 +1679,6 @@ void PenTool::_bsplineSpiroEndAnchorOff()
this->sa_overwrited->reset();
this->sa_overwrited = tmp_curve->copy();
}
- tmp_curve->unref();
}
//prepares the curves for its transformation into BSpline curve.
@@ -1694,6 +1692,7 @@ void PenTool::_bsplineSpiroBuild()
SPCurve *curve = new SPCurve();
//If we continuate the existing curve we add it at the start
if(this->sa && !this->sa->curve->is_unset()){
+ delete curve;
curve = this->sa_overwrited->copy();
}
@@ -1862,13 +1861,13 @@ void PenTool::_finishSegment(Geom::Point const p, guint const state) {
if(!this->green_curve->is_unset() &&
!Geom::are_near(*this->green_curve->last_point(),this->p[0]))
{
- SPCurve *lsegment = new SPCurve();
+ std::unique_ptr<SPCurve> lsegment(new SPCurve());
Geom::CubicBezier const * cubic = dynamic_cast<Geom::CubicBezier const*>(&*this->green_curve->last_segment());
if (cubic) {
lsegment->moveto((*cubic)[0]);
lsegment->curveto((*cubic)[1], this->p[0] - ((*cubic)[2] - (*cubic)[3]), *this->red_curve->first_point());
this->green_curve->backspace();
- this->green_curve->append_continuous(lsegment, 0.0625);
+ this->green_curve->append_continuous(lsegment.get(), 0.0625);
}
}
this->green_curve->append_continuous(this->red_curve, 0.0625);