[Bf-blender-cvs] [982fdbf] asset-experiments: FileBrowser: Various fixes...

Bastien Montagne noreply at git.blender.org
Tue Mar 31 16:03:38 CEST 2015


Commit: 982fdbf50612d61b0c7cf235f26fa7deefaba2eb
Author: Bastien Montagne
Date:   Mon Mar 30 22:25:14 2015 +0200
Branches: asset-experiments
https://developer.blender.org/rB982fdbf50612d61b0c7cf235f26fa7deefaba2eb

FileBrowser: Various fixes...

Stupid useless allocations, memleaks, etc.

WIP, thumbnails still not working.

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

M	intern/guardedalloc/intern/mallocn_guarded_impl.c
M	source/blender/editors/space_file/file_draw.c
M	source/blender/editors/space_file/filelist.c
M	source/blender/editors/space_file/filesel.c

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

diff --git a/intern/guardedalloc/intern/mallocn_guarded_impl.c b/intern/guardedalloc/intern/mallocn_guarded_impl.c
index bdcace2..78a5661 100644
--- a/intern/guardedalloc/intern/mallocn_guarded_impl.c
+++ b/intern/guardedalloc/intern/mallocn_guarded_impl.c
@@ -76,7 +76,7 @@
  * memory block was allocated and print this trace for all
  * unfreed blocks.
  */
-//#define DEBUG_BACKTRACE
+#define DEBUG_BACKTRACE
 
 #ifdef DEBUG_BACKTRACE
 #  define BACKTRACE_SIZE 100
diff --git a/source/blender/editors/space_file/file_draw.c b/source/blender/editors/space_file/file_draw.c
index 020497a..f7b556c 100644
--- a/source/blender/editors/space_file/file_draw.c
+++ b/source/blender/editors/space_file/file_draw.c
@@ -35,6 +35,7 @@
 #include "BLI_blenlib.h"
 #include "BLI_utildefines.h"
 #include "BLI_fileops_types.h"
+#include "BLI_math.h"
 
 #ifdef WIN32
 #  include "BLI_winstuff.h"
@@ -484,8 +485,8 @@ void file_draw_list(const bContext *C, ARegion *ar)
 
 	align = (FILE_IMGDISPLAY == params->display) ? UI_STYLE_TEXT_CENTER : UI_STYLE_TEXT_LEFT;
 
-	{
-		const bool success = filelist_file_cache_block(files, offset + (numfiles_layout / 2));
+	if (numfiles > 0) {
+		const bool success = filelist_file_cache_block(files, min_ii(offset + (numfiles_layout / 2), numfiles - 1));
 		BLI_assert(success);
 		UNUSED_VARS_NDEBUG(success);
 	}
diff --git a/source/blender/editors/space_file/filelist.c b/source/blender/editors/space_file/filelist.c
index cbe1d01..8c28df8 100644
--- a/source/blender/editors/space_file/filelist.c
+++ b/source/blender/editors/space_file/filelist.c
@@ -694,7 +694,7 @@ void filelist_filter(FileList *filelist)
 	memcpy(filelist->filelist_intern.filtered, filtered_tmp,
 	       sizeof(*filelist->filelist_intern.filtered) * (size_t)num_filtered);
 	filelist->filelist.nbr_entries_filtered = num_filtered;
-	printf("%d/%d\n", num_filtered, filelist->filelist.nbr_entries);
+//	printf("Filetered: %d over %d entries\n", num_filtered, filelist->filelist.nbr_entries);
 
 	MEM_freeN(filtered_tmp);
 }
@@ -1153,6 +1153,7 @@ static void filelist_cache_free(FileListEntryCache *cache)
 	/* Note we nearly have nothing to do here, entries are just 'borrowed', not owned by cache... */
 	if (cache->misc_entries) {
 		BLI_ghash_free(cache->misc_entries, NULL, NULL);
+		cache->misc_entries = NULL;
 	}
 }
 
@@ -1166,10 +1167,6 @@ static void filelist_cache_clear(FileListEntryCache *cache)
 	if (cache->misc_entries) {
 		BLI_ghash_clear_ex(cache->misc_entries, NULL, NULL, FILELIST_ENTRYCACHESIZE);
 	}
-	else {
-		cache->misc_entries = BLI_ghash_ptr_new_ex(__func__, FILELIST_ENTRYCACHESIZE);
-		cache->misc_cursor = 0;
-	}
 }
 
 FileList *filelist_new(short type)
@@ -1353,7 +1350,8 @@ static FileDirEntry *filelist_file_ex(struct FileList *filelist, const int index
 	if (!use_request) {
 		return NULL;
 	}
-//	printf("requesting file %d (not yet cached)\n", index);
+
+	printf("requesting file %d (not yet cached)\n", index);
 
 	/* Else, we have to add new entry to 'misc' cache - and possibly make room for it first! */
 	ret = filelist_intern_create_entry(filelist, index);
@@ -1365,9 +1363,11 @@ static FileDirEntry *filelist_file_ex(struct FileList *filelist, const int index
 	cache->misc_entries_indices[cache->misc_cursor] = index;
 	cache->misc_cursor = (cache->misc_cursor + 1) % FILELIST_ENTRYCACHESIZE;
 
+#if 0  /* Actually no, only block cached entries should have preview imho. */
 	if (cache->previews_pool) {
 		filelist_cache_previews_push(filelist, ret, index);
 	}
+#endif
 
 	return ret;
 }
@@ -1409,6 +1409,7 @@ bool filelist_file_cache_block(struct FileList *filelist, const int index)
 	int i;
 
 	if ((index < 0) || (index >= nbr_entries)) {
+		printf("Wrong index %d ([%d:%d])", index, 0, nbr_entries);
 		return false;
 	}
 
@@ -1545,7 +1546,7 @@ void filelist_cache_previews_set(FileList *filelist, const bool use_previews)
 		int num_tasks = 4;
 		int i;
 
-		BLI_assert((cache->previews_pool == NULL) && (cache->previews_todo = NULL) && (cache->previews_done == NULL));
+		BLI_assert((cache->previews_pool == NULL) && (cache->previews_todo == NULL) && (cache->previews_done == NULL));
 
 		pool = cache->previews_pool = BLI_task_pool_create(scheduler, NULL);
 		cache->previews_todo = BLI_thread_queue_init();
diff --git a/source/blender/editors/space_file/filesel.c b/source/blender/editors/space_file/filesel.c
index c7aa684..446990b 100644
--- a/source/blender/editors/space_file/filesel.c
+++ b/source/blender/editors/space_file/filesel.c
@@ -775,6 +775,7 @@ void ED_fileselect_exit(struct wmWindowManager *wm, struct SpaceFile *sfile)
 	
 	if (sfile->files) {
 		ED_fileselect_clear(wm, sfile);
+		filelist_free(sfile->files);
 		MEM_freeN(sfile->files);
 		sfile->files = NULL;
 	}




More information about the Bf-blender-cvs mailing list