From 8c7e58b3d53d4d26e2631f5a69df1f4084d58bb3 Mon Sep 17 00:00:00 2001 From: tildearrow Date: Fri, 14 Jan 2022 00:34:22 -0500 Subject: [PATCH] GUI: only open file if able to save --- src/gui/gui.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp index 1c6ab3e7c..2f492b937 100644 --- a/src/gui/gui.cpp +++ b/src/gui/gui.cpp @@ -2576,11 +2576,6 @@ void FurnaceGUI::openFileDialog(FurnaceGUIFileDialogs type) { #define FURNACE_ZLIB_COMPRESS int FurnaceGUI::save(String path) { - FILE* outFile=fopen(path.c_str(),"wb"); - if (outFile==NULL) { - lastError=strerror(errno); - return 1; - } SafeWriter* w; if (path.rfind(".dmf")==path.size()-4) { w=e->saveDMF(); @@ -2589,9 +2584,14 @@ int FurnaceGUI::save(String path) { } if (w==NULL) { lastError=e->getLastError(); - fclose(outFile); return 3; } + FILE* outFile=fopen(path.c_str(),"wb"); + if (outFile==NULL) { + lastError=strerror(errno); + w->finish(); + return 1; + } #ifdef FURNACE_ZLIB_COMPRESS unsigned char zbuf[131072]; int ret;