Repository: godot
Issue: Export: Save a File: Godot doesn't update Quick Access folders if changed after opening editor, causing offset display or even out-of-bounds error
Labels: bug,platform:linuxbsd,topic:editor,topic:thirdparty

### Tested versions

- Reproducible in: v4.2.1.stable.official [b09f793f5]

### System information

Godot v4.2.1.stable - Ubuntu 22.04.3 LTS 22.04 - X11 - Vulkan (Mobile) - dedicated NVIDIA GeForce GTX 860M (nvidia; 535.154.05) - Intel(R) Core(TM) i7-4710HQ CPU @ 2.50GHz (8 Threads)

### Issue description

After changing a my favorite folders on my system, I was exporting a project manually via Project > Export... > Export Project... > Save a File popup and noticed some weird behavior when with the top-right Quick Access dropdown window.

When I enter a directory that happens to be in the Quick Access list (on Ubuntu, it would be the list of favorite folders in Nautilus - which is different from Godot's own favorites), the Quick Access dropdown at the top-right will, for a certain range of folders (but not all), display the previous folder in the list (the one just above the actually opened folder in the vertical list).

This happens whether I opened the folder by double-clicking it in the main area, or by selecting it with the Quick Access dropdown (which means the selection won't even match what I just clicked).

The actual folder content, however, is correct. So this is not a breaking bug, but a display bug.

Note that Godot sorts favorites alphabetically unlike Nautilus.

**Potential cause**

It appears that I had modified my favorite folders in Nautilus *after* opening Godot, but Godot didn't refresh its own list. A removed favorite folder will cause the displayed folder index to be decremented, an added favorite folder will cause the displayed folder index to be incremented. This also means that adding/removing many favorite folders can cause out of bounds.
So the issue is that Godot stores an old list of favorite folders, but somewhat accesses the current list, which messes up with the selection index.

Out-of-bounds error ex:

> scene/gui/option_button.cpp:421 - Index p_which = 34 is out of bounds (popup->get_item_count() = 33).

Below, note how Music is shown as Hidden Music:

![2024-02-16 Export Save a File Quick Access Folder picks sometimes previous folder](https://github.com/godotengine/godot/assets/1067772/2d1d4fcc-8176-492f-b93b-e6e49fdebd4d)

### Steps to reproduce

1. Create a bunch of favorite folders in your file browser (e.g. Nautilus), not necessarily in alphabetical order, and some with common parent folders (Ctrl+D in Nautilus)
2. Open a Godot project and Project > Export... > Export Project... > Save a File popup
3. Open some favorite folders, directly or via the Quick Access dropdown, one by one => OK
4. Now add some folders to your file browser favorites and repeat 3 => the displayed folders are more below in the list, sometimes causing an out-of-bounds error
5. Now remove favorite folders, even more than the number you added, to cause a negative offset, and repeat 3 => the displayed folders are more above in the list, sometimes causing an out-of-bounds error

### Minimal reproduction project (MRP)

N/A