Delete output file when gcode conversion fails

This commit is contained in:
enricoturri1966 2023-07-27 10:22:22 +02:00
parent f02e8e3438
commit 2cde917f11

View File

@ -5442,9 +5442,7 @@ void Plater::convert_gcode_to_ascii()
public:
explicit ScopedFile(FILE* file) : m_file(file) {}
~ScopedFile() { if (m_file != nullptr) fclose(m_file); }
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
void unscope() { m_file = nullptr; }
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
private:
FILE* m_file{ nullptr };
};
@ -5478,11 +5476,9 @@ void Plater::convert_gcode_to_ascii()
if (res != bgcode::EResult::Success) {
MessageDialog msg_dlg(this, _L(bgcode::translate_result(res)), _L("Error converting gcode file"), wxICON_INFORMATION | wxOK);
msg_dlg.ShowModal();
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
scoped_out_file.unscope();
fclose(out_file);
boost::nowide::remove(output_file.c_str());
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
return;
}
}