Fix improper handling of NULL dialog filter on Cocoa
This commit is contained in:
@@ -37,6 +37,7 @@ void show_file_dialog(cocoa_FileDialogType type, SDL_DialogFileCallback callback
|
||||
SDL_SetError("tvOS and iOS don't support path-based file dialogs");
|
||||
callback(userdata, NULL, -1);
|
||||
#else
|
||||
if (filters) {
|
||||
const char *msg = validate_filters(filters);
|
||||
|
||||
if (msg) {
|
||||
@@ -44,6 +45,7 @@ void show_file_dialog(cocoa_FileDialogType type, SDL_DialogFileCallback callback
|
||||
callback(userdata, NULL, -1);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (SDL_GetHint(SDL_HINT_FILE_DIALOG_DRIVER) != NULL) {
|
||||
SDL_SetError("File dialog driver unsupported");
|
||||
@@ -73,6 +75,7 @@ void show_file_dialog(cocoa_FileDialogType type, SDL_DialogFileCallback callback
|
||||
break;
|
||||
};
|
||||
|
||||
if (filters) {
|
||||
int n = -1;
|
||||
while (filters[++n].name && filters[n].pattern);
|
||||
// On macOS 11.0 and up, this is an array of UTType. Prior to that, it's an array of NSString
|
||||
@@ -118,6 +121,7 @@ void show_file_dialog(cocoa_FileDialogType type, SDL_DialogFileCallback callback
|
||||
[dialog setAllowedFileTypes:types];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Keep behavior consistent with other platforms */
|
||||
[dialog setAllowsOtherFileTypes:YES];
|
||||
|
||||
Reference in New Issue
Block a user