Fix "Native Filechooser (Zenity) crashes on second invocation" (#665)

This commit is contained in:
ManoloFLTK 2023-01-31 13:13:48 +01:00
parent 1045538ed0
commit 9bf2726bce
2 changed files with 3 additions and 2 deletions

View File

@ -170,7 +170,6 @@ int Fl_Kdialog_Native_File_Chooser_Driver::show() {
}
}
delete[] command;
if (_title) { free(_title); _title = NULL; }
if (!pipe) return -1;
return (data.all_files == NULL ? 1 : 0);
}

View File

@ -77,7 +77,8 @@ char *Fl_Zenity_Native_File_Chooser_Driver::build_command() {
snprintf(command+l, lcommand-l, " %s %s ", option, preset ? preset : "");
delete[] preset;
if (_parsedfilt) {
char *p = strtok(_parsedfilt, "\n");
char *parsed_filter_copy = strdup(_parsedfilt); // keep _parsedfilt unchanged for re-use
char *p = strtok(parsed_filter_copy, "\n");
while (p) {
char *op = strchr(p, '(');
l = strlen(command);
@ -105,6 +106,7 @@ char *Fl_Zenity_Native_File_Chooser_Driver::build_command() {
}
p = strtok(NULL, "\n");
}
free(parsed_filter_copy);
}
strcat(command, " 2> /dev/null"); // get rid of stderr output
//puts(command);