tseli0s/nvdialog

[BUG] Windows code ignores cancel on open/save dialogs.

Closed this issue · 1 comments

rj45 commented

The return value of the following functions is ignored, which is a BOOL indicating if the ok button was pressed, or cancel/close:

if (dialog->is_save_dialog) GetSaveFileName(&ofn);
else GetOpenFileName(&ofn);

I fixed it like this, but you may want to do it differently:

  if (dialog->is_save_dialog)
    dialog->location_was_chosen = GetSaveFileName(&ofn);
  else
    dialog->location_was_chosen = GetOpenFileName(&ofn);

I then check dialog->location_was_chosen before I strdup() the string and return it. That way the string doesn't need to be freed if dialog->location_was_chosen is false.

That fix seems fine, make a pull request and I'll merge it.