Linux handle zenity non-zero code. Close #301

This commit is contained in:
2023-01-08 10:39:40 -07:00
committed by Celtic Minstrel
parent 36cd2997d3
commit dbe5ba0dd6

View File

@@ -145,12 +145,17 @@ static std::string runFileDialog(const std::string& file, bool save) {
if (fgets(buffer, 128, hfile) != NULL)
filename += buffer;
}
// When the dialogue is canceled, return empty string.
int result = pclose(hfile);
if (result != 0) {
return "";
}
// Remove possible unwanted newline included from end of popen() output
if (filename[filename.length()-1] == '\n')
filename.erase(filename.length()-1);
pclose(hfile);
return filename;
}