[Bf-blender-cvs] [53148b5] asset-experiments: Some flatmode fixes:

Bastien Montagne noreply at git.blender.org
Sat Dec 6 14:53:54 CET 2014


Commit: 53148b5ebc806eb1574e519416e6eb3666979227
Author: Bastien Montagne
Date:   Sat Dec 6 14:50:03 2014 +0100
Branches: asset-experiments
https://developer.blender.org/rB53148b5ebc806eb1574e519416e6eb3666979227

Some flatmode fixes:

* Delete filelist when changing flat setting (so that we get immediate update when changing that setting).
* Disable flat when going up in tree (we ;ight actually want to do this everytime).

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

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

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

diff --git a/source/blender/editors/space_file/file_ops.c b/source/blender/editors/space_file/file_ops.c
index df3f989..577a0c0 100644
--- a/source/blender/editors/space_file/file_ops.c
+++ b/source/blender/editors/space_file/file_ops.c
@@ -178,18 +178,26 @@ static FileSelect file_select_do(bContext *C, int selected_idx, bool do_diropen)
 		params->active_file = selected_idx;
 
 		if (S_ISDIR(file->type)) {
+			const bool is_parent_dir = STREQ(file->relname, "..");
+
 			if (do_diropen == false) {
 				params->file[0] = '\0';
 				retval = FILE_SELECT_DIR;
 			}
 			/* the path is too long and we are not going up! */
-			else if (strcmp(file->relname, "..") && strlen(params->dir) + strlen(file->relname) >= FILE_MAX) {
+			else if (!is_parent_dir && strlen(params->dir) + strlen(file->relname) >= FILE_MAX) {
 				// XXX error("Path too long, cannot enter this directory");
 			}
 			else {
-				if (strcmp(file->relname, "..") == 0) {
+				if (is_parent_dir) {
 					/* avoids /../../ */
 					BLI_parent_dir(params->dir);
+
+					if (params->flag & FILE_SHOWFLAT) {
+						/* Disable 'show flat' when going up in tree! */
+						params->flag &= ~FILE_SHOWFLAT;
+						filelist_setrecursive(sfile->files, false);
+					}
 				}
 				else {
 					BLI_cleanup_dir(G.main->name, params->dir);
@@ -871,6 +879,11 @@ int file_parent_exec(bContext *C, wmOperator *UNUSED(unused))
 			else {
 				file_change_dir(C, 1);
 			}
+			if (sfile->params->flag & FILE_SHOWFLAT) {
+				/* Disable 'show flat' when going up in tree! */
+				sfile->params->flag &= ~FILE_SHOWFLAT;
+				filelist_setrecursive(sfile->files, false);
+			}
 			WM_event_add_notifier(C, NC_SPACE | ND_SPACE_FILE_LIST, NULL);
 		}
 	}
diff --git a/source/blender/editors/space_file/filelist.c b/source/blender/editors/space_file/filelist.c
index ecfdff9..f6fa6c4 100644
--- a/source/blender/editors/space_file/filelist.c
+++ b/source/blender/editors/space_file/filelist.c
@@ -645,7 +645,14 @@ void filelist_setdir(struct FileList *filelist, const char *dir)
 
 void filelist_setrecursive(struct FileList *filelist, const bool use_recursion)
 {
+	const bool do_free = (filelist->use_recursion != use_recursion);
+
 	filelist->use_recursion = use_recursion;
+
+	if (do_free) {
+		filelist_freelib(filelist);
+		filelist_free(filelist);
+	}
 }
 
 void filelist_imgsize(struct FileList *filelist, short w, short h)




More information about the Bf-blender-cvs mailing list