fix [#32564] Entries in recent list (file select dialog) don't get pushed to top if used again
This commit is contained in:
@@ -770,8 +770,9 @@ int file_exec(bContext *C, wmOperator *exec_op)
|
||||
|
||||
file_sfile_to_operator(op, sfile, filepath);
|
||||
|
||||
if (BLI_exists(sfile->params->dir))
|
||||
fsmenu_insert_entry(fsmenu_get(), FS_CATEGORY_RECENT, sfile->params->dir, FS_INSERT_SAVE);
|
||||
if (BLI_exists(sfile->params->dir)) {
|
||||
fsmenu_insert_entry(fsmenu_get(), FS_CATEGORY_RECENT, sfile->params->dir, FS_INSERT_SAVE | FS_INSERT_FIRST);
|
||||
}
|
||||
|
||||
BLI_make_file_string(G.main->name, filepath, BLI_get_folder_create(BLENDER_USER_CONFIG, NULL), BLENDER_BOOKMARK_FILE);
|
||||
fsmenu_write_file(fsmenu_get(), filepath);
|
||||
|
@@ -164,14 +164,22 @@ void fsmenu_insert_entry(struct FSMenu *fsmenu, FSMenuCategory category, const c
|
||||
FSMenuEntry *prev;
|
||||
FSMenuEntry *fsme;
|
||||
FSMenuEntry *fsms;
|
||||
FSMenuEntry *fsms_first;
|
||||
|
||||
fsms = fsmenu_get_category(fsmenu, category);
|
||||
prev = fsme = fsms;
|
||||
prev = fsme = fsms_first = fsms;
|
||||
|
||||
for (; fsme; prev = fsme, fsme = fsme->next) {
|
||||
if (fsme->path) {
|
||||
const int cmp_ret = BLI_path_cmp(path, fsme->path);
|
||||
if (cmp_ret == 0) {
|
||||
if (FS_INSERT_FIRST) {
|
||||
if (fsme != fsms_first) {
|
||||
prev->next = fsme->next;
|
||||
fsme->next = fsms_first;
|
||||
fsmenu_set_category(fsmenu, category, fsme);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
else if ((flag & FS_INSERT_SORTED) && cmp_ret < 0) {
|
||||
|
@@ -45,7 +45,8 @@ typedef enum FSMenuCategory {
|
||||
|
||||
typedef enum FSMenuInsert {
|
||||
FS_INSERT_SORTED = (1 << 0),
|
||||
FS_INSERT_SAVE = (1 << 1)
|
||||
FS_INSERT_SAVE = (1 << 1),
|
||||
FS_INSERT_FIRST = (1 << 2) /* moves the item to the front of the list when its already there */
|
||||
} FSMenuInsert;
|
||||
|
||||
struct FSMenu;
|
||||
|
Reference in New Issue
Block a user