[Bf-blender-cvs] [8608a0f] master: added new "Fake User" option for appending objects, this sets a fake user on each newly appended item except Groups and Objects.

Martin Felke noreply at git.blender.org
Mon Jan 4 14:03:58 CET 2016


Commit: 8608a0f4f0e17e14d0b2d560914767c776778619
Author: Martin Felke
Date:   Mon Jan 4 14:02:05 2016 +0100
Branches: master
https://developer.blender.org/rB8608a0f4f0e17e14d0b2d560914767c776778619

added new "Fake User" option for appending objects, this sets a fake user on each newly appended item except Groups and Objects.

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

M	source/blender/blenkernel/BKE_library.h
M	source/blender/blenkernel/intern/blender.c
M	source/blender/blenkernel/intern/library.c
M	source/blender/editors/object/object_relations.c
M	source/blender/python/intern/bpy_library.c
M	source/blender/windowmanager/intern/wm_operators.c

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

diff --git a/source/blender/blenkernel/BKE_library.h b/source/blender/blenkernel/BKE_library.h
index 7af126f..9c5e5e5 100644
--- a/source/blender/blenkernel/BKE_library.h
+++ b/source/blender/blenkernel/BKE_library.h
@@ -116,7 +116,7 @@ void BKE_main_lib_objects_recalc_all(struct Main *bmain);
 /* (MAX_ID_NAME - 2) + 3 */
 void BKE_id_ui_prefix(char name[66 + 1], const struct ID *id);
 
-void BKE_library_make_local(struct Main *bmain, struct Library *lib, bool untagged_only);
+void BKE_library_make_local(struct Main *bmain, struct Library *lib, bool untagged_only, bool set_fake);
 
 typedef void (*BKE_library_free_window_manager_cb)(struct bContext *, struct wmWindowManager *);
 typedef void (*BKE_library_free_notifier_reference_cb)(const void *);
diff --git a/source/blender/blenkernel/intern/blender.c b/source/blender/blenkernel/intern/blender.c
index 8b44737..ef9cce3 100644
--- a/source/blender/blenkernel/intern/blender.c
+++ b/source/blender/blenkernel/intern/blender.c
@@ -1080,7 +1080,7 @@ int BKE_copybuffer_paste(bContext *C, const char *libname, ReportList *reports)
 	
 	/* append, rather than linking */
 	lib = BLI_findstring(&bmain->library, libname, offsetof(Library, filepath));
-	BKE_library_make_local(bmain, lib, true);
+	BKE_library_make_local(bmain, lib, true, false);
 	
 	/* important we unset, otherwise these object wont
 	 * link into other scenes from this blend file */
diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c
index bfee7c1..736b2f6 100644
--- a/source/blender/blenkernel/intern/library.c
+++ b/source/blender/blenkernel/intern/library.c
@@ -1760,7 +1760,7 @@ void BKE_main_id_tag_all(struct Main *mainvar, const bool tag)
 
 /* if lib!=NULL, only all from lib local
  * bmain is almost certainly G.main */
-void BKE_library_make_local(Main *bmain, Library *lib, bool untagged_only)
+void BKE_library_make_local(Main *bmain, Library *lib, bool untagged_only, bool set_fake)
 {
 	ListBase *lbarray[MAX_LIBARRAY];
 	ID *id, *idn;
@@ -1797,7 +1797,15 @@ void BKE_library_make_local(Main *bmain, Library *lib, bool untagged_only)
 						id->tag &= ~(LIB_TAG_EXTERN | LIB_TAG_INDIRECT | LIB_TAG_NEW);
 					}
 				}
+
+				if (set_fake) {
+					if (!ELEM( GS(id->name), ID_OB, ID_GR)) {
+						/* do not set fake user on objects, groups (instancing) */
+						id_fake_user_set(id);
+					}
+				}
 			}
+
 			id = idn;
 		}
 	}
diff --git a/source/blender/editors/object/object_relations.c b/source/blender/editors/object/object_relations.c
index 32a7806..b390fc1 100644
--- a/source/blender/editors/object/object_relations.c
+++ b/source/blender/editors/object/object_relations.c
@@ -2220,7 +2220,7 @@ static int make_local_exec(bContext *C, wmOperator *op)
 			           "Orphan library objects added to the current scene to avoid loss");
 		}
 
-		BKE_library_make_local(bmain, NULL, false); /* NULL is all libs */
+		BKE_library_make_local(bmain, NULL, false, false); /* NULL is all libs */
 		WM_event_add_notifier(C, NC_WINDOW, NULL);
 		return OPERATOR_FINISHED;
 	}
diff --git a/source/blender/python/intern/bpy_library.c b/source/blender/python/intern/bpy_library.c
index d241a76..3561f2b 100644
--- a/source/blender/python/intern/bpy_library.c
+++ b/source/blender/python/intern/bpy_library.c
@@ -416,7 +416,7 @@ static PyObject *bpy_lib_exit(BPy_Library *self, PyObject *UNUSED(args))
 
 			/* append, rather than linking */
 			if ((self->flag & FILE_LINK) == 0) {
-				BKE_library_make_local(bmain, lib, true);
+				BKE_library_make_local(bmain, lib, true, false);
 			}
 		}
 
diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c
index 7ee5f36..ca36c11 100644
--- a/source/blender/windowmanager/intern/wm_operators.c
+++ b/source/blender/windowmanager/intern/wm_operators.c
@@ -2700,7 +2700,8 @@ static int wm_link_append_exec(bContext *C, wmOperator *op)
 
 	/* append, rather than linking */
 	if ((flag & FILE_LINK) == 0) {
-		BKE_library_make_local(bmain, NULL, true);
+		bool set_fake = RNA_boolean_get(op->ptr, "set_fake");
+		BKE_library_make_local(bmain, NULL, true, set_fake);
 	}
 
 	/* important we unset, otherwise these object wont
@@ -2779,6 +2780,7 @@ static void WM_OT_append(wmOperatorType *ot)
 		FILE_DEFAULTDISPLAY, FILE_SORT_ALPHA);
 
 	wm_link_append_properties_common(ot, false);
+	RNA_def_boolean(ot->srna, "set_fake", false, "Fake User", "Set Fake User for appended items (except Objects and Groups)");
 }
 
 /* *************** recover last session **************** */




More information about the Bf-blender-cvs mailing list