From 0518f6e13e143d4b0b0349a137da1ea9629d1e42 Mon Sep 17 00:00:00 2001
From: twinaphex <libretro@gmail.com>
Date: Sun, 7 Mar 2021 20:00:45 +0100
Subject: [PATCH] Create MENU_ENTRIES_NEEDS_REFRESH

---
 retroarch.c      | 16 +++++-----------
 retroarch_data.h |  3 ++-
 2 files changed, 7 insertions(+), 12 deletions(-)

diff --git a/retroarch.c b/retroarch.c
index d1018d25f2..dab5208d9b 100644
--- a/retroarch.c
+++ b/retroarch.c
@@ -1874,7 +1874,7 @@ static int generic_menu_iterate(
    p_rarch->menu_driver_is_binding = iterate_type == ITERATE_TYPE_BIND;
 
    if (     action != MENU_ACTION_NOOP
-         || menu_entries_ctl(MENU_ENTRIES_CTL_NEEDS_REFRESH, NULL)
+         || MENU_ENTRIES_NEEDS_REFRESH(menu_st)
          || GFX_DISPLAY_GET_UPDATE_PENDING(p_anim, p_disp))
    {
       BIT64_SET(menu->state, MENU_STATE_RENDER_FRAMEBUFFER);
@@ -2285,7 +2285,7 @@ int generic_menu_entry_action(
 
    if (cbs && cbs->action_refresh)
    {
-      if (menu_entries_ctl(MENU_ENTRIES_CTL_NEEDS_REFRESH, NULL))
+      if (MENU_ENTRIES_NEEDS_REFRESH(menu_st))
       {
          bool refresh            = false;
          struct menu_state  
@@ -2404,7 +2404,7 @@ void menu_entry_get(menu_entry_t *entry, size_t stack_idx,
    menu_file_list_cbs_t *cbs   = NULL;
    struct rarch_state *p_rarch = &rarch_st;
    struct menu_state *menu_st  = &p_rarch->menu_driver_state;
-   file_list_t *selection_buf  = MENU_ENTRIES_GET_SELECTION_BUF_PTR_INTERNAL(stack_idx);
+   file_list_t *selection_buf  = MENU_ENTRIES_GET_SELECTION_BUF_PTR_INTERNAL(menu_st, stack_idx);
    file_list_t *list           = (userdata) ? (file_list_t*)userdata : selection_buf;
    bool path_enabled           = entry->path_enabled;
 
@@ -3132,7 +3132,7 @@ void menu_entries_prepend(file_list_t *list,
       unsigned type, size_t directory_ptr, size_t entry_idx)
 {
    menu_ctx_list_t list_info;
-   size_t idx;
+   size_t idx                      = 0;
    const char *menu_path           = NULL;
    menu_file_list_cbs_t *cbs       = NULL;
    struct rarch_state   *p_rarch   = &rarch_st;
@@ -3143,8 +3143,6 @@ void menu_entries_prepend(file_list_t *list,
 
    menu_entries_get_last_stack(&menu_path, NULL, NULL, NULL, NULL);
 
-   idx              = 0;
-
    list_info.fullpath    = NULL;
 
    if (!string_is_empty(menu_path))
@@ -3296,11 +3294,7 @@ bool menu_entries_ctl(enum menu_entries_ctl_state state, void *data)
    switch (state)
    {
       case MENU_ENTRIES_CTL_NEEDS_REFRESH:
-         if (menu_st->entries_nonblocking_refresh)
-            return false;
-         if (!menu_st->entries_need_refresh)
-            return false;
-         break;
+         return MENU_ENTRIES_NEEDS_REFRESH(menu_st);
       case MENU_ENTRIES_CTL_SETTINGS_GET:
          {
             rarch_setting_t **settings  = (rarch_setting_t**)data;
diff --git a/retroarch_data.h b/retroarch_data.h
index 64e263c8c1..5ca446ffc7 100644
--- a/retroarch_data.h
+++ b/retroarch_data.h
@@ -284,7 +284,8 @@
 
 #define MENU_LIST_GET_STACK_SIZE(list, idx) ((list)->menu_stack[(idx)]->size)
 
-#define MENU_ENTRIES_GET_SELECTION_BUF_PTR_INTERNAL(idx) ((menu_st->entries.list) ? MENU_LIST_GET_SELECTION(menu_st->entries.list, (unsigned)idx) : NULL)
+#define MENU_ENTRIES_GET_SELECTION_BUF_PTR_INTERNAL(menu_st, idx) ((menu_st->entries.list) ? MENU_LIST_GET_SELECTION(menu_st->entries.list, (unsigned)idx) : NULL)
+#define MENU_ENTRIES_NEEDS_REFRESH(menu_st) (!(menu_st->entries_nonblocking_refresh || !menu_st->entries_need_refresh))
 #endif
 
 #define CDN_URL "https://cdn.discordapp.com/avatars"