[Bf-blender-cvs] [d9b1f13a6a1] temp-lanpr-cleanup: UI: Avoid file browser directory change if path didn't change

Julian Eisel noreply at git.blender.org
Wed Sep 25 03:49:24 CEST 2019


Commit: d9b1f13a6a18d45e2f42706da0646b0e8cb8594d
Author: Julian Eisel
Date:   Fri Sep 20 20:41:00 2019 +0200
Branches: temp-lanpr-cleanup
https://developer.blender.org/rBd9b1f13a6a18d45e2f42706da0646b0e8cb8594d

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