[Bf-blender-cvs] [574d63c] asset-engine: Merge branch 'master' into asset-engine

Bastien Montagne noreply at git.blender.org
Mon Dec 7 11:00:58 CET 2015


Commit: 574d63cf65102950e426e6e72a8227f528c30bef
Author: Bastien Montagne
Date:   Mon Dec 7 11:00:38 2015 +0100
Branches: asset-engine
https://developer.blender.org/rB574d63cf65102950e426e6e72a8227f528c30bef

Merge branch 'master' into asset-engine

Conflicts:
	source/blender/editors/space_file/file_intern.h
	source/blender/editors/space_file/file_ops.c

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



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

diff --cc source/blender/blenkernel/intern/library.c
index 0f7c3f4,f1e0bc6..7402271
--- a/source/blender/blenkernel/intern/library.c
+++ b/source/blender/blenkernel/intern/library.c
@@@ -1610,13 -1629,9 +1629,10 @@@ void id_clear_lib_data(Main *bmain, ID 
  
  	BKE_id_lib_local_paths(bmain, id->lib, id);
  
- 	if (id->flag & LIB_FAKEUSER) {
- 		id->us--;
- 		id->flag &= ~LIB_FAKEUSER;
- 	}
+ 	id_fake_user_clear(id);
  
  	id->lib = NULL;
 +	MEM_SAFE_FREE(id->uuid);  /* Local ID have no more use for asset-related data. */
  	id->flag = LIB_LOCAL;
  	new_id(which_libbase(bmain, GS(id->name)), id, NULL);
  
diff --cc source/blender/editors/space_file/file_intern.h
index 53c8f5a,71e38f7..2153fdb
--- a/source/blender/editors/space_file/file_intern.h
+++ b/source/blender/editors/space_file/file_intern.h
@@@ -107,7 -108,12 +108,11 @@@ void file_filename_enter_handle(bContex
  
  int file_highlight_set(struct SpaceFile *sfile, struct ARegion *ar, int mx, int my);
  
+ void file_sfile_filepath_set(struct SpaceFile *sfile, const char *filepath);
 -void file_sfile_to_operator_ex(struct wmOperator *op, struct SpaceFile *sfile, char *filepath);
++void file_sfile_to_operator_ex(struct wmOperator *op, struct SpaceFile *sfile, char *filepath, const bool is_fake);
+ void file_sfile_to_operator(struct wmOperator *op, struct SpaceFile *sfile);
+ void file_operator_to_sfile(struct SpaceFile *sfile, struct wmOperator *op);
  
 -
  /* filesel.c */
  void fileselect_file_set(SpaceFile *sfile, const int index);
  float file_string_width(const char *str);
diff --cc source/blender/editors/space_file/file_ops.c
index 9d3530a,ccd1b7c..dc75ca8
--- a/source/blender/editors/space_file/file_ops.c
+++ b/source/blender/editors/space_file/file_ops.c
@@@ -1190,142 -1188,84 +1190,149 @@@ void FILE_OT_cancel(struct wmOperatorTy
  }
  
  
- static void file_sfile_to_operator(
 -void file_sfile_to_operator_ex(wmOperator *op, SpaceFile *sfile, char *filepath)
++void file_sfile_to_operator_ex(
 +        wmOperator *op, SpaceFile *sfile, char filepath[FILE_MAX_LIBEXTRA], const bool is_fake)
  {
 -	PropertyRNA *prop;
 +	PropertyRNA *prop, *prop_files, *prop_dirs;
 +	/* Note filebrowser does not create ae for default NONE 'engine', we'll get NULL in this case here. */
 +	AssetEngine *ae = filelist_assetengine_get(sfile->files);
 +	AssetUUIDList *uuids;
 +	FileDirEntryArr *selection;
 +	FileCheckType check = CHECK_NONE;
  
 -	BLI_join_dirfile(filepath, FILE_MAX, sfile->params->dir, sfile->params->file); /* XXX, not real length */
 -
 -	if ((prop = RNA_struct_find_property(op->ptr, "relative_path"))) {
 -		if (RNA_property_boolean_get(op->ptr, prop)) {
 -			BLI_path_rel(filepath, G.main->name);
 -		}
 +	if ((prop_files = RNA_struct_find_property(op->ptr, "files"))) {
 +	    check |= CHECK_FILES;
  	}
 +	if ((prop_dirs = RNA_struct_find_property(op->ptr, "dirs"))) {
 +		check |= CHECK_DIRS;
 +	}
 +
 +	BLI_assert(STREQ(sfile->params->dir, filelist_dir(sfile->files)));
 +
 +	selection = filelist_selection_get(sfile->files, check, sfile->params->file, &uuids, !is_fake);
  
 -	if ((prop = RNA_struct_find_property(op->ptr, "filename"))) {
 -		RNA_property_string_set(op->ptr, prop, sfile->params->file);
 +	if (ae && selection->nbr_entries && !is_fake) {  /* We only expect uuids when not is_fake... */
 +		BLI_assert(uuids);
  	}
 +
  	if ((prop = RNA_struct_find_property(op->ptr, "directory"))) {
 -		RNA_property_string_set(op->ptr, prop, sfile->params->dir);
 -	}
 -	if ((prop = RNA_struct_find_property(op->ptr, "filepath"))) {
 -		RNA_property_string_set(op->ptr, prop, filepath);
 +		RNA_property_string_set(op->ptr, prop, selection->root);
  	}
 -	
 -	/* some ops have multiple files to select */
 -	/* this is called on operators check() so clear collections first since
 -	 * they may be already set. */
 -	{
 -		int i, numfiles = filelist_files_ensure(sfile->files);
  
 -		if ((prop = RNA_struct_find_property(op->ptr, "files"))) {
 -			PointerRNA itemptr;
 -			int num_files = 0;
 -			RNA_property_collection_clear(op->ptr, prop);
 -			for (i = 0; i < numfiles; i++) {
 -				if (filelist_entry_select_index_get(sfile->files, i, CHECK_FILES)) {
 -					FileDirEntry *file = filelist_file(sfile->files, i);
 -					RNA_property_collection_add(op->ptr, prop, &itemptr);
 -					RNA_string_set(&itemptr, "name", file->relpath);
 -					num_files++;
 -				}
 +	if (selection->nbr_entries != 0) {
 +		const char *filename;
 +
 +		filename = ((FileDirEntry *)selection->entries.first)->relpath;
 +		BLI_join_dirfile(filepath, FILE_MAX_LIBEXTRA /* XXX sizeof(filepath) */, selection->root, filename);
 +
 +		if ((prop = RNA_struct_find_property(op->ptr, "relative_path"))) {
 +			if (RNA_property_boolean_get(op->ptr, prop)) {
 +				BLI_path_rel(filepath, G.main->name);
  			}
 -			/* make sure the file specified in the filename button is added even if no files selected */
 -			if (0 == num_files) {
 -				RNA_property_collection_add(op->ptr, prop, &itemptr);
 -				RNA_string_set(&itemptr, "name", sfile->params->file);
 +		}
 +
 +		if ((prop = RNA_struct_find_property(op->ptr, "filename"))) {
 +			RNA_property_string_set(op->ptr, prop, filename);
 +		}
 +		if ((prop = RNA_struct_find_property(op->ptr, "filepath"))) {
 +			RNA_property_string_set(op->ptr, prop, filepath);
 +		}
 +		if (ae && uuids) {
 +			if ((prop = RNA_struct_find_property(op->ptr, "asset_uuid"))) {
 +				RNA_property_int_set_array(op->ptr, prop, uuids->uuids[0].uuid_asset);
 +			}
 +			if ((prop = RNA_struct_find_property(op->ptr, "variant_uuid"))) {
 +				RNA_property_int_set_array(op->ptr, prop, uuids->uuids[0].uuid_variant);
 +			}
 +			if ((prop = RNA_struct_find_property(op->ptr, "revision_uuid"))) {
 +				RNA_property_int_set_array(op->ptr, prop, uuids->uuids[0].uuid_revision);
  			}
  		}
  
 -		if ((prop = RNA_struct_find_property(op->ptr, "dirs"))) {
 -			PointerRNA itemptr;
 -			int num_dirs = 0;
 -			RNA_property_collection_clear(op->ptr, prop);
 -			for (i = 0; i < numfiles; i++) {
 -				if (filelist_entry_select_index_get(sfile->files, i, CHECK_DIRS)) {
 -					FileDirEntry *file = filelist_file(sfile->files, i);
 -					RNA_property_collection_add(op->ptr, prop, &itemptr);
 -					RNA_string_set(&itemptr, "name", file->relpath);
 -					num_dirs++;
 +		/* some ops have multiple files to select */
 +		/* this is called on operators check() so clear collections first since
 +		 * they may be already set. */
 +		{
 +			if (prop_files) {
 +				FileDirEntry *entry;
 +				PointerRNA itemptr;
 +				int i;
 +
 +				RNA_property_collection_clear(op->ptr, prop_files);
 +				for (i = 0, entry = selection->entries.first; entry; entry = entry->next, i++) {
 +					if (!(entry->typeflag & FILE_TYPE_DIR)) {
 +						RNA_property_collection_add(op->ptr, prop_files, &itemptr);
 +						RNA_string_set(&itemptr, "name", entry->relpath);
 +						if (ae) {
 +							BLI_assert(i < uuids->nbr_uuids);
 +							RNA_int_set_array(&itemptr, "asset_uuid", uuids->uuids[i].uuid_asset);
 +							RNA_int_set_array(&itemptr, "variant_uuid", uuids->uuids[i].uuid_variant);
 +							RNA_int_set_array(&itemptr, "revision_uuid", uuids->uuids[i].uuid_revision);
 +						}
 +					}
  				}
  			}
 -			
 -			/* make sure the directory specified in the button is added even if no directory selected */
 -			if (0 == num_dirs) {
 -				RNA_property_collection_add(op->ptr, prop, &itemptr);
 -				RNA_string_set(&itemptr, "name", sfile->params->dir);
 +
 +			if (prop_dirs) {
 +				FileDirEntry *entry;
 +				PointerRNA itemptr;
 +				int num_dirs = 0;
 +
 +				RNA_property_collection_clear(op->ptr, prop);
 +				for (entry = selection->entries.first; entry; entry = entry->next) {
 +					if (entry->typeflag & FILE_TYPE_DIR) {
 +						RNA_property_collection_add(op->ptr, prop_dirs, &itemptr);
 +						RNA_string_set(&itemptr, "name", entry->relpath);
 +						num_dirs++;
 +					}
 +				}
 +
 +				/* make sure the directory specified in the button is added even if no directory selected */
 +				if (!num_dirs) {
 +					RNA_property_collection_add(op->ptr, prop_dirs, &itemptr);
 +					RNA_string_set(&itemptr, "name", sfile->params->dir);
 +				}
  			}
  		}
 +	}
 +	else {
 +		/* We have to ensure those are properly reset!!! */
 +		if ((prop = RNA_struct_find_property(op->ptr, "filename"))) {
 +			RNA_property_string_set(op->ptr, prop, sfile->params->file);
 +		}
 +		if ((prop = RNA_struct_find_property(op->ptr, "filepath"))) {
 +			BLI_join_dirfile(filepath, FILE_MAX_LIBEXTRA, sfile->params->dir, sfile->params->file);
 +			RNA_property_string_set(op->ptr, prop, filepath);
 +		}
 +		if (prop_files) {
 +			RNA_property_reset(op->ptr, prop, 0);
 +		}
 +		if (prop_dirs) {
 +			RNA_property_reset(op->ptr, prop, 0);
 +		}
 +	}
  
 +	if (!is_fake && ae && (prop = RNA_struct_find_property(op->ptr, "asset_engine"))) {
 +		RNA_property_string_set(op->ptr, prop, ae->type->idname);
 +	}
  
 +	if (uuids) {
 +		MEM_freeN(uuids->uuids);
 +		MEM_freeN(uuids);
  	}
 +
 +	BKE_filedir_entryarr_clear(selection);
 +	MEM_freeN(selection);
  }
 +
- static void file_operator_to_sfile(SpaceFile *sfile, wmOperator *op)
+ void file_sfile_to_operator(wmOperator *op, SpaceFile *sfile)
+ {
+ 	char filepath[FILE_MAX];
+ 
 -	file_sfile_to_operator_ex(op, sfile, filepath);
++	file_sfile_to_operator_ex(op, sfile, filepath, false);
+ }
+ 
+ void file_operator_to_sfile(SpaceFile *sfile, wmOperator *op)
  {
  	PropertyRNA *prop;
  
@@@ -1357,8 -1319,7 +1386,8 @@@ void file_draw_check(bContext *C
  	wmOperator *op = sfile->op;
  	if (op) { /* fail on reload */
  		if (op->type->check) {
 -			file_sfile_to_operator(op, sfile);
 +			char filepath[FILE_MAX_LIBEXTRA];
- 			file_sfile_to_operator(op, sfile, filepath, true);
++			file_sfile_to_operator_ex(op, sfile, filepath, true);
  			
  			/* redraw */
  			if (op->type->check(C, op)) {
@@@ -1441,7 -1402,7 +1470,7 @@@ int file_exec(bContext *C, wmOperator *
  		
  		sfile->op = NULL;
  
- 		file_sfile_to_operator(op, sfile, filepath, false);
 -		file_sfile_to_operator_ex(op, sfile, filepath);
++		file_sfile_to_operator_ex(op, sfile, filepath, false);
  
  		if (BLI_exists(sfile->params->dir)) {
  			fsmenu_insert_entry(ED_fsmenu_get(), FS_CATEGORY_RECENT, sfile->params->dir, NULL,
diff --cc sourc

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list