From b66a796f0bdc9307fa05a3aef5574fe1acf71887 Mon Sep 17 00:00:00 2001 From: Alessandro Ranellucci Date: Sun, 7 Jul 2013 15:18:32 +0200 Subject: [PATCH 1/2] Silence t/freeze.t --- t/freeze.t | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/t/freeze.t b/t/freeze.t index f48cf04c8..07fd020d2 100644 --- a/t/freeze.t +++ b/t/freeze.t @@ -16,12 +16,13 @@ use Time::HiRes qw(gettimeofday tv_interval); my $t0 = [gettimeofday]; my $print = Slic3r::Test::init_print('20mm_cube', scale => 2); my $gcode = Slic3r::Test::gcode($print); - diag sprintf 'Slicing took %s seconds', tv_interval($t0); + ###diag sprintf 'Slicing took %s seconds', tv_interval($t0); my $t1 = [gettimeofday]; nstore $print, 'print.dat'; $print = retrieve 'print.dat'; - diag sprintf 'Freezing and retrieving took %s seconds', tv_interval($t1); + unlink 'print.dat'; + ###diag sprintf 'Freezing and retrieving took %s seconds', tv_interval($t1); isa_ok $print, 'Slic3r::Print', 'restored Print object'; } From f4db7625bc0f53e65b92b433e2a3a0c08aa6ad69 Mon Sep 17 00:00:00 2001 From: Alessandro Ranellucci Date: Sun, 7 Jul 2013 16:51:02 +0200 Subject: [PATCH 2/2] Fix destructors --- xs/src/ExPolygon.hpp | 9 ++++----- xs/xsp/ExPolygon.xsp | 6 ++++-- xs/xsp/Point.xsp | 1 + 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/xs/src/ExPolygon.hpp b/xs/src/ExPolygon.hpp index 0ee9c28a6..7e77a3814 100644 --- a/xs/src/ExPolygon.hpp +++ b/xs/src/ExPolygon.hpp @@ -21,21 +21,20 @@ class ExPolygon SV* arrayref(); }; -Polygon* -perl2polygon(SV* poly_sv) +void +perl2polygon(SV* poly_sv, Polygon& poly) { AV* poly_av = (AV*)SvRV(poly_sv); const unsigned int num_points = av_len(poly_av)+1; - Polygon* retval = new Polygon(num_points); + poly.resize(num_points); for (unsigned int i = 0; i < num_points; i++) { SV** point_sv = av_fetch(poly_av, i, 0); AV* point_av = (AV*)SvRV(*point_sv); - Point& p = (*retval)[i]; + Point& p = poly[i]; p.x = (unsigned long)SvIV(*av_fetch(point_av, 0, 0)); p.y = (unsigned long)SvIV(*av_fetch(point_av, 1, 0)); } - return retval; } SV* diff --git a/xs/xsp/ExPolygon.xsp b/xs/xsp/ExPolygon.xsp index a69fd26b6..e0442efcc 100644 --- a/xs/xsp/ExPolygon.xsp +++ b/xs/xsp/ExPolygon.xsp @@ -6,6 +6,7 @@ %} %name{Slic3r::ExPolygon::XS} class ExPolygon { + ~ExPolygon(); %{ ExPolygon* @@ -13,9 +14,10 @@ ExPolygon::new(...) CODE: RETVAL = new ExPolygon (); // ST(0) is class name, ST(1) is contour and others are holes - RETVAL->contour = *perl2polygon(ST(1)); + perl2polygon(ST(1), RETVAL->contour); + RETVAL->holes.resize(items-2); for (unsigned int i = 2; i < items; i++) { - RETVAL->holes.push_back(*perl2polygon(ST(i))); + perl2polygon(ST(i), RETVAL->holes[i-2]); } OUTPUT: RETVAL diff --git a/xs/xsp/Point.xsp b/xs/xsp/Point.xsp index 372d1edd0..ef18931fe 100644 --- a/xs/xsp/Point.xsp +++ b/xs/xsp/Point.xsp @@ -7,6 +7,7 @@ %name{Slic3r::Point::XS} class Point { Point(unsigned long _x = 0, unsigned long _y = 0); + ~Point(); %{ SV*