From 83166a7ff3e9e659339e1f7b466b23729cfdbad1 Mon Sep 17 00:00:00 2001 From: bubnikv Date: Fri, 15 Apr 2016 17:57:38 +0200 Subject: [PATCH] Close SVG file when the object gets deallocated. --- xs/src/libslic3r/SVG.cpp | 1 + xs/src/libslic3r/SVG.hpp | 2 ++ 2 files changed, 3 insertions(+) diff --git a/xs/src/libslic3r/SVG.cpp b/xs/src/libslic3r/SVG.cpp index 444810044..259c6eacf 100644 --- a/xs/src/libslic3r/SVG.cpp +++ b/xs/src/libslic3r/SVG.cpp @@ -204,6 +204,7 @@ SVG::Close() { fprintf(this->f, "\n"); fclose(this->f); + this->f = NULL; printf("SVG written to %s\n", this->filename.c_str()); } diff --git a/xs/src/libslic3r/SVG.hpp b/xs/src/libslic3r/SVG.hpp index 94cfc27dd..aa08c0e20 100644 --- a/xs/src/libslic3r/SVG.hpp +++ b/xs/src/libslic3r/SVG.hpp @@ -17,6 +17,8 @@ class SVG SVG(const char* filename); SVG(const char* filename, const BoundingBox &bbox); + ~SVG() { if (f != NULL) Close(); } + void draw(const Line &line, std::string stroke = "black", coord_t stroke_width = 0); void draw(const ThickLine &line, const std::string &fill, const std::string &stroke, coord_t stroke_width = 0); void draw(const Lines &lines, std::string stroke = "black");