[Bf-blender-cvs] [ac15bf16462] master: UI: Avoid file browser directory change if path didn't change

Julian Eisel noreply at git.blender.org
Fri Sep 20 20:49:45 CEST 2019


Commit: ac15bf16462b79265eac70091f40d0ca0cde77b0
Author: Julian Eisel
Date:   Fri Sep 20 20:41:00 2019 +0200
Branches: master
https://developer.blender.org/rBac15bf16462b79265eac70091f40d0ca0cde77b0

UI: Avoid file browser directory change if path didn't change

E.g. entering the file path field and then pressing enter without any
change would call an unneccesary directory change, causing flickering.
So the main point of this is to avoid flickering.

Without this the text field could also be used to refresh the file list,
but for that we have a proper button.

===================================================================

M	source/blender/editors/space_file/file_ops.c

===================================================================

diff --git a/source/blender/editors/space_file/file_ops.c b/source/blender/editors/space_file/file_ops.c
index 48cded9073f..b4b51de302d 100644
--- a/source/blender/editors/space_file/file_ops.c
+++ b/source/blender/editors/space_file/file_ops.c
@@ -2149,6 +2149,10 @@ void file_directory_enter_handle(bContext *C, void *UNUSED(arg_unused), void *UN
   SpaceFile *sfile = CTX_wm_space_file(C);
 
   if (sfile->params) {
+    char old_dir[sizeof(sfile->params->dir)];
+
+    BLI_strncpy(old_dir, sfile->params->dir, sizeof(old_dir));
+
     file_expand_directory(C);
 
     /* special case, user may have pasted a filepath into the directory */
@@ -2182,8 +2186,10 @@ void file_directory_enter_handle(bContext *C, void *UNUSED(arg_unused), void *UN
     BLI_cleanup_dir(BKE_main_blendfile_path(bmain), sfile->params->dir);
 
     if (filelist_is_dir(sfile->files, sfile->params->dir)) {
-      /* if directory exists, enter it immediately */
-      ED_file_change_dir(C);
+      if (!STREQ(sfile->params->dir, old_dir)) { /* Avoids flickering when nothing's changed. */
+        /* if directory exists, enter it immediately */
+        ED_file_change_dir(C);
+      }
 
       /* don't do for now because it selects entire text instead of
        * placing cursor at the end */



More information about the Bf-blender-cvs mailing list