From bb6a42f8f031c84e47b463f725b50fdcc9ce93a1 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 18 May 2019 08:21:14 +0200 Subject: [PATCH] (menu_entries) Create action_title_cache --- menu/cbs/menu_cbs_title.c | 8 ++++---- menu/menu_entries.c | 13 ++++++++++++- menu/menu_entries.h | 1 + 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/menu/cbs/menu_cbs_title.c b/menu/cbs/menu_cbs_title.c index a8d3b22299..12c76664aa 100644 --- a/menu/cbs/menu_cbs_title.c +++ b/menu/cbs/menu_cbs_title.c @@ -43,7 +43,7 @@ static int action_get_title_action_generic(const char *path, const char *label, { sanitize_to_string(s, label, len); } - return 0; + return 1; } #define default_title_macro(func_name, lbl) \ @@ -54,7 +54,7 @@ static int action_get_title_action_generic(const char *path, const char *label, { \ sanitize_to_string(s, str, len); \ } \ - return 0; \ + return 1; \ } #define default_fill_title_macro(func_name, lbl) \ @@ -63,14 +63,14 @@ static int action_get_title_action_generic(const char *path, const char *label, const char *title = msg_hash_to_str(lbl); \ if (!string_is_empty(path) && !string_is_empty(title)) \ fill_pathname_join_delim(s, title, path, ' ', len); \ - return 0; \ + return 1; \ } #define default_title_copy_macro(func_name, lbl) \ static int (func_name)(const char *path, const char *label, unsigned menu_type, char *s, size_t len) \ { \ strlcpy(s, msg_hash_to_str(lbl), len); \ - return 0; \ + return 1; \ } static int action_get_title_dropdown_item(const char *path, const char *label, unsigned menu_type, char *s, size_t len) diff --git a/menu/menu_entries.c b/menu/menu_entries.c index c070ab664a..b5c3f9a135 100644 --- a/menu/menu_entries.c +++ b/menu/menu_entries.c @@ -895,7 +895,18 @@ int menu_entries_get_title(char *s, size_t len) menu_entries_get_last_stack(&path, &label, &menu_type, &enum_idx, NULL); if (cbs && cbs->action_get_title) - return cbs->action_get_title(path, label, menu_type, s, len); + { + int ret; + if (!string_is_empty(cbs->action_title_cache)) + { + strlcpy(s, cbs->action_title_cache, len); + return 0; + } + ret = cbs->action_get_title(path, label, menu_type, s, len); + if (ret == 1) + strlcpy(cbs->action_title_cache, s, sizeof(cbs->action_title_cache)); + return ret; + } return 0; } diff --git a/menu/menu_entries.h b/menu/menu_entries.h index 6baddb93d3..d30d0bb85f 100644 --- a/menu/menu_entries.h +++ b/menu/menu_entries.h @@ -81,6 +81,7 @@ typedef struct menu_ctx_list typedef struct menu_file_list_cbs { char action_sublabel_cache[512]; + char action_title_cache [512]; enum msg_hash_enums enum_idx; const char *action_iterate_ident;