mirror of
https://github.com/libretro/RetroArch
synced 2025-02-01 00:32:46 +00:00
Merge pull request #9265 from jdgleaver/shader-menu-fix
(Menu) Prevent undefined behaviour when failing to load shaders
This commit is contained in:
commit
249621fa75
@ -4679,6 +4679,10 @@ MSG_HASH(
|
||||
MSG_FAILED_TO_APPLY_SHADER,
|
||||
"Failed to apply shader."
|
||||
)
|
||||
MSG_HASH(
|
||||
MSG_FAILED_TO_APPLY_SHADER_PRESET,
|
||||
"Failed to apply shader preset:"
|
||||
)
|
||||
MSG_HASH(
|
||||
MSG_FAILED_TO_BIND_SOCKET,
|
||||
"Failed to bind socket."
|
||||
|
@ -5713,8 +5713,8 @@ void general_write_handler(rarch_setting_t *setting)
|
||||
settings->bools.video_shader_enable = false;
|
||||
}
|
||||
}
|
||||
/* TODO/FIXME - fallthrough here intentional? */
|
||||
#endif
|
||||
break;
|
||||
case MENU_ENUM_LABEL_VIDEO_THREADED:
|
||||
{
|
||||
if (*setting->value.target.boolean)
|
||||
|
@ -158,7 +158,32 @@ bool menu_shader_manager_set_preset(void *data,
|
||||
|
||||
if (!video_driver_set_shader(type, preset_path))
|
||||
{
|
||||
configuration_set_bool(settings, settings->bools.video_shader_enable, false);
|
||||
char msg[PATH_MAX_LENGTH];
|
||||
const char *preset_file = NULL;
|
||||
|
||||
msg[0] = '\0';
|
||||
|
||||
/* Display error message */
|
||||
if (!string_is_empty(preset_path))
|
||||
preset_file = path_basename(preset_path);
|
||||
|
||||
snprintf(msg, sizeof(msg), "%s %s",
|
||||
msg_hash_to_str(MSG_FAILED_TO_APPLY_SHADER_PRESET),
|
||||
string_is_empty(preset_file) ? "(null)" : preset_file);
|
||||
|
||||
runloop_msg_queue_push(
|
||||
msg, 1, 180, true, NULL,
|
||||
MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_ERROR);
|
||||
|
||||
/* We don't want to disable shaders entirely here,
|
||||
* just reset number of passes
|
||||
* > Note: Disabling shaders at this point would in
|
||||
* fact be dangerous, since it changes the number of
|
||||
* entries in the shader options menu which can in
|
||||
* turn lead to the menu selection pointer going out
|
||||
* of bounds. This causes undefined behaviour/segfaults */
|
||||
menu_shader_manager_clear_num_passes();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -389,6 +389,7 @@ enum msg_hash_enums
|
||||
MSG_STATE_SLOT,
|
||||
MSG_STARTING_MOVIE_RECORD_TO,
|
||||
MSG_FAILED_TO_APPLY_SHADER,
|
||||
MSG_FAILED_TO_APPLY_SHADER_PRESET,
|
||||
MSG_APPLYING_SHADER,
|
||||
MSG_SHADER,
|
||||
MSG_REDIRECTING_SAVESTATE_TO,
|
||||
|
Loading…
x
Reference in New Issue
Block a user