[Bf-blender-cvs] [211ef29] asset-experiments: Merge branch 'master' into asset-experiments

Bastien Montagne noreply at git.blender.org
Wed Aug 19 22:38:56 CEST 2015


Commit: 211ef292ba14541a8741b0b906f98aed40540c33
Author: Bastien Montagne
Date:   Wed Aug 19 21:54:20 2015 +0200
Branches: asset-experiments
https://developer.blender.org/rB211ef292ba14541a8741b0b906f98aed40540c33

Merge branch 'master' into asset-experiments

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



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

diff --cc source/blender/windowmanager/intern/wm_operators.c
index 59bdb33,15aab9f..516164b
--- a/source/blender/windowmanager/intern/wm_operators.c
+++ b/source/blender/windowmanager/intern/wm_operators.c
@@@ -2596,116 -2594,24 +2596,117 @@@ static short wm_link_append_flag(wmOper
  	return flag;
  }
  
 -static int wm_link_append_exec(bContext *C, wmOperator *op)
 +/* Helper.
 + *     if `name` is non-NULL, we assume a single-item link/append.
 + *     else if `*todo_libraries` is NULL we assume first-run.
 + */
 +static void wm_link_append_do_libgroup(
 +        bContext *C, wmOperator *op, const char *root, const char *libname, char *group, char *name,
 +        const short flag, GSet **todo_libraries)
  {
  	Main *bmain = CTX_data_main(C);
 -	Scene *scene = CTX_data_scene(C);
 -	Main *mainl = NULL;
 +	Main *mainl;
  	BlendHandle *bh;
  	Library *lib;
 +
 +	char path[FILE_MAX_LIBEXTRA], relname[FILE_MAX];
 +	int idcode;
 +	const bool is_first_run = (*todo_libraries == NULL);
 +
 +	BLI_assert(group);
 +	idcode = BKE_idcode_from_name(group);
 +
 +	bh = BLO_blendhandle_from_file(libname, op->reports);
 +
 +	if (bh == NULL) {
 +		/* unlikely since we just browsed it, but possible
 +		 * error reports will have been made by BLO_blendhandle_from_file() */
 +		return;
 +	}
 +
 +	/* here appending/linking starts */
 +	mainl = BLO_library_append_begin(bmain, &bh, libname);
 +	lib = mainl->curlib;
 +	BLI_assert(lib);
 +
 +	if (mainl->versionfile < 250) {
 +		BKE_reportf(op->reports, RPT_WARNING,
 +		            "Linking or appending from a very old .blend file format (%d.%d), no animation conversion will "
 +		            "be done! You may want to re-save your lib file with current Blender",
 +		            mainl->versionfile, mainl->subversionfile);
 +	}
 +
 +	if (name) {
 +		BLO_library_append_named_part_ex(C, mainl, &bh, name, idcode, flag);
 +	}
 +	else {
 +		if (is_first_run) {
 +			*todo_libraries = BLI_gset_new(BLI_ghashutil_strhash_p, BLI_ghashutil_strcmp, __func__);
 +		}
 +
 +		RNA_BEGIN (op->ptr, itemptr, "files")
 +		{
 +			char curr_libname[FILE_MAX];
 +			int curr_idcode;
 +
 +			RNA_string_get(&itemptr, "name", relname);
 +
 +			BLI_join_dirfile(path, sizeof(path), root, relname);
 +
 +			if (BLO_library_path_explode(path, curr_libname, &group, &name)) {
 +				if (!group || !name) {
 +					continue;
 +				}
 +
 +				curr_idcode = BKE_idcode_from_name(group);
 +
 +				if ((idcode == curr_idcode) && (BLI_path_cmp(curr_libname, libname) == 0)) {
 +					BLO_library_append_named_part_ex(C, mainl, &bh, name, idcode, flag);
 +				}
 +				else if (is_first_run) {
 +					BLI_join_dirfile(path, sizeof(path), curr_libname, group);
 +					if (!BLI_gset_haskey(*todo_libraries, path)) {
 +						BLI_gset_insert(*todo_libraries, BLI_strdup(path));
 +					}
 +				}
 +			}
 +		}
 +		RNA_END;
 +	}
 +	BLO_library_append_end(C, mainl, &bh, idcode, flag);
 +
 +	BLO_blendhandle_close(bh);
 +
 +	/* mark all library linked objects to be updated */
 +	BKE_main_lib_objects_recalc_all(bmain);
 +	IMB_colormanagement_check_file_config(bmain);
 +
 +	/* append, rather than linking */
 +	if ((flag & FILE_LINK) == 0) {
 +		BLI_assert(BLI_findindex(&bmain->library, lib) != -1);
 +		BKE_library_make_local(bmain, lib, true);
 +	}
 +}
 +
 +static int wm_link_append_exec(bContext *C, wmOperator *op)
 +{
 +	Main *bmain = CTX_data_main(C);
 +	Scene *scene = CTX_data_scene(C);
  	PropertyRNA *prop;
- 	char path[FILE_MAX_LIBEXTRA], root[FILE_MAXDIR], libname[FILE_MAX], relname[FILE_MAX], *group, *name;
 -	char name[FILE_MAX], dir[FILE_MAX], libname[FILE_MAX];
 -	char *group;
 -	int idcode, totfiles = 0;
++	char path[FILE_MAX_LIBEXTRA], root[FILE_MAXDIR], libname[FILE_MAX], relname[FILE_MAX];
++	char *group, *name;
 +	int totfiles = 0;
  	short flag;
  
 -	RNA_string_get(op->ptr, "filename", name);
 -	RNA_string_get(op->ptr, "directory", dir);
 +	GSet *todo_libraries = NULL;
 +
 +	RNA_string_get(op->ptr, "filename", relname);
 +	RNA_string_get(op->ptr, "directory", root);
 +
 +	BLI_join_dirfile(path, sizeof(path), root, relname);
  
  	/* test if we have a valid data */
 -	if (BLO_library_path_explode(dir, libname, &group, NULL) == 0) {
 +	if (!BLO_library_path_explode(path, libname, &group, &name)) {
  		BKE_report(op->reports, RPT_ERROR, "Not a library");
  		return OPERATOR_CANCELLED;
  	}




More information about the Bf-blender-cvs mailing list