GUI: only open file if able to save

This commit is contained in:
tildearrow 2022-01-14 00:34:22 -05:00
parent 6d2aa8d23e
commit 8c7e58b3d5
1 changed files with 6 additions and 6 deletions

View File

@ -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;