From 7892dfd53c083f7b5c26dad04dca0f84ab29b2a7 Mon Sep 17 00:00:00 2001 From: bubnikv Date: Tue, 5 Dec 2017 18:40:46 +0100 Subject: Fixed a regression bug in G-code export, where ferror was called on released FILE structure. --- xs/src/libslic3r/GCode.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'xs/src/libslic3r/GCode.cpp') diff --git a/xs/src/libslic3r/GCode.cpp b/xs/src/libslic3r/GCode.cpp index 131693b4e..528d7132b 100644 --- a/xs/src/libslic3r/GCode.cpp +++ b/xs/src/libslic3r/GCode.cpp @@ -376,11 +376,13 @@ void GCode::do_export(Print *print, const char *path) this->m_placeholder_parser_failed_templates.clear(); this->_do_export(*print, file); - fclose(file); + fflush(file); if (ferror(file)) { + fclose(file); boost::nowide::remove(path_tmp.c_str()); throw std::runtime_error(std::string("G-code export to ") + path + " failed\nIs the disk full?\n"); } + fclose(file); if (! this->m_placeholder_parser_failed_templates.empty()) { // G-code export proceeded, but some of the PlaceholderParser substitutions failed. std::string msg = std::string("G-code export to ") + path + " failed due to invalid custom G-code sections:\n\n"; -- cgit v1.2.3