[Bf-blender-cvs] [0929283] asset-experiments: Merge branch 'master' into asset-experiments
Bastien Montagne
noreply at git.blender.org
Tue May 24 15:54:21 CEST 2016
Commit: 0929283ddc7946c906a49043db9e8649841acf64
Author: Bastien Montagne
Date: Tue May 24 15:48:55 2016 +0200
Branches: asset-experiments
https://developer.blender.org/rB0929283ddc7946c906a49043db9e8649841acf64
Merge branch 'master' into asset-experiments
===================================================================
===================================================================
diff --cc source/blender/blenkernel/BKE_library.h
index 7dec790,2215fbf..8048c1c
--- a/source/blender/blenkernel/BKE_library.h
+++ b/source/blender/blenkernel/BKE_library.h
@@@ -151,25 -119,12 +151,26 @@@ void BKE_main_lib_objects_recalc_all(st
/* (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, bool set_fake);
+ void BKE_library_make_local(
+ struct Main *bmain, const struct Library *lib, const bool untagged_only, const bool set_fake);
+void BKE_library_asset_repository_init(struct Library *lib, const struct AssetEngineType *aet, const char *repo_root);
+void BKE_library_asset_repository_clear(struct Library *lib);
+void BKE_library_asset_repository_free(struct Library *lib);
+struct AssetRef *BKE_library_asset_repository_asset_add(struct Library *lib, const void *idv);
+void BKE_library_asset_repository_asset_remove(struct Library *lib, const void *idv);
+struct AssetRef *BKE_library_asset_repository_asset_find(struct Library *lib, const void *idv);
+void BKE_library_asset_repository_subdata_add(struct AssetRef *aref, const void *idv);
+void BKE_library_asset_repository_subdata_remove(struct AssetRef *aref, const void *idv);
+
+void BKE_libraries_asset_subdata_remove(struct Main *bmain, const void *idv);
+void BKE_libraries_asset_repositories_clear(struct Main *bmain);
+void BKE_libraries_asset_repositories_rebuild(struct Main *bmain);
+struct AssetRef *BKE_libraries_asset_repository_uuid_find(struct Main *bmain, const struct AssetUUID *uuid);
+
typedef void (*BKE_library_free_window_manager_cb)(struct bContext *, struct wmWindowManager *);
typedef void (*BKE_library_free_notifier_reference_cb)(const void *);
-typedef void (*BKE_library_free_editor_id_reference_cb)(const struct ID *);
+typedef void (*BKE_library_remap_editor_id_reference_cb)(struct ID *, struct ID *);
void BKE_library_callback_free_window_manager_set(BKE_library_free_window_manager_cb func);
void BKE_library_callback_free_notifier_reference_set(BKE_library_free_notifier_reference_cb func);
diff --cc source/blender/editors/space_file/filelist.c
index 26762cd,8e1f781..3d0270e
--- a/source/blender/editors/space_file/filelist.c
+++ b/source/blender/editors/space_file/filelist.c
@@@ -1513,50 -1419,39 +1513,50 @@@ bool filelist_pending(struct FileList *
* Limited version of full update done by space_file's file_refresh(), to be used by operators and such.
* Ensures given filelist is ready to be used (i.e. it is filtered and sorted), unless it is tagged for a full refresh.
*/
-int filelist_files_ensure(FileList *filelist)
+int filelist_files_ensure(FileList *filelist, FileSelectParams *params)
{
if (!filelist_force_reset(filelist) || !filelist_empty(filelist)) {
- filelist_sort(filelist);
- filelist_filter(filelist);
+ filelist_sort_filter(filelist, params);
}
- return filelist->filelist.nbr_entries_filtered;;
+ return filelist->filelist.nbr_entries_filtered;
}
+
+static FileDirEntry *filelist_file_create_entries_block(FileList *filelist, const int index, const int size);
+
static FileDirEntry *filelist_file_create_entry(FileList *filelist, const int index)
{
- FileListInternEntry *entry = filelist->filelist_intern.filtered[index];
FileListEntryCache *cache = &filelist->filelist_cache;
FileDirEntry *ret;
- FileDirEntryRevision *rev;
- ret = MEM_callocN(sizeof(*ret), __func__);
- rev = MEM_callocN(sizeof(*rev), __func__);
+ if (filelist->ae) {
+ ret = filelist_file_create_entries_block(filelist, index, 1);
- rev->size = (uint64_t)entry->st.st_size;
+ BLI_assert(!ret || !ret->next);
+ }
+ else {
+ FileListInternEntry *entry = filelist->filelist_intern.filtered[index];
+ FileDirEntryRevision *rev;
+
+ ret = MEM_callocN(sizeof(*ret), __func__);
+ rev = MEM_callocN(sizeof(*rev), __func__);
- rev->time = (int64_t)entry->st.st_mtime;
+ rev->size = (uint64_t)entry->st.st_size;
- ret->entry = rev;
- ret->relpath = BLI_strdup(entry->relpath);
- ret->name = BLI_strdup(entry->name);
- ret->description = BLI_strdupcat(filelist->filelist.root, entry->relpath);
- memcpy(ret->uuid, entry->uuid, sizeof(ret->uuid));
- ret->blentype = entry->blentype;
- ret->typeflag = entry->typeflag;
+ rev->time = (int64_t)entry->st.st_mtime;
+
+ ret->entry = rev;
+ ret->relpath = BLI_strdup(entry->relpath);
+ ret->name = BLI_strdup(entry->name);
+ ret->description = BLI_strdupcat(filelist->filelist.root, entry->relpath);
+ memcpy(ret->uuid, entry->uuid, sizeof(ret->uuid));
+ ret->blentype = entry->blentype;
+ ret->typeflag = entry->typeflag;
+
+ BLI_addtail(&cache->cached_entries, ret);
+ }
- BLI_addtail(&cache->cached_entries, ret);
return ret;
}
diff --cc source/blender/windowmanager/intern/wm_files_link.c
index ed5b380,2e4a4b6..8901d26
--- a/source/blender/windowmanager/intern/wm_files_link.c
+++ b/source/blender/windowmanager/intern/wm_files_link.c
@@@ -527,798 -513,8 +547,801 @@@ 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)");
+ RNA_def_boolean(ot->srna, "set_fake", false, "Fake User",
+ "Set Fake User for appended items (except Objects and Groups)");
+ RNA_def_boolean(ot->srna, "use_recursive", true, "Localize All",
+ "Localize all appended data, including those indirectly linked from other libraries");
}
+
+/** \name Reload/relocate libraries.
+ *
+ * \{ */
+
+static int wm_lib_relocate_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
+{
+ Library *lib;
+ char lib_name[MAX_NAME];
+
+ RNA_string_get(op->ptr, "library", lib_name);
+ lib = (Library *)BKE_libblock_find_name_ex(CTX_data_main(C), ID_LI, lib_name);
+
+ if (lib) {
+ if (lib->parent) {
+ BKE_reportf(op->reports, RPT_ERROR_INVALID_INPUT,
+ "Cannot relocate indirectly linked library '%s'", lib->filepath);
+ return OPERATOR_CANCELLED;
+ }
+ RNA_string_set(op->ptr, "filepath", lib->filepath);
+
+ WM_event_add_fileselect(C, op);
+
+ return OPERATOR_RUNNING_MODAL;
+ }
+
+ return OPERATOR_CANCELLED;
+}
+
+/* Note that IDs listed in lapp_data items *must* have been removed from bmain by caller. */
+static void lib_relocate_do(Main *bmain, WMLinkAppendData *lapp_data, ReportList *reports, const bool do_reload)
+{
+ ListBase *lbarray[MAX_LIBARRAY];
+ int lba_idx;
+
+ LinkNode *itemlink;
+ int item_idx;
+
+ BKE_main_id_tag_all(bmain, LIB_TAG_PRE_EXISTING, true);
+
+ /* We do not want any instanciation here! */
+ wm_link_do(lapp_data, reports, bmain, NULL, NULL, NULL, do_reload, do_reload);
+
+ BKE_main_lock(bmain);
+
+ /* We add back old id to bmain.
+ * We need to do this in a first, separated loop, otherwise some of those may not be handled by
+ * ID remapping, which means they would still reference old data to be deleted... */
+ for (item_idx = 0, itemlink = lapp_data->items.list; itemlink; item_idx++, itemlink = itemlink->next) {
+ WMLinkAppendDataItem *item = itemlink->link;
+ ID *old_id = item->customdata;
+
+ BLI_assert(old_id);
+ BLI_addtail(which_libbase(bmain, GS(old_id->name)), old_id);
+ }
+
+ /* Note that in reload case, we also want to replace indirect usages. */
+ const short remap_flags = ID_REMAP_SKIP_NEVER_NULL_USAGE | (do_reload ? 0 : ID_REMAP_SKIP_INDIRECT_USAGE);
+ for (item_idx = 0, itemlink = lapp_data->items.list; itemlink; item_idx++, itemlink = itemlink->next) {
+ WMLinkAppendDataItem *item = itemlink->link;
+ ID *old_id = item->customdata;
+ ID *new_id = item->new_id;
+
+ BLI_assert(old_id);
+ if (do_reload) {
+ /* Since we asked for placeholders in case of missing IDs, we expect to always get a valid one. */
+ BLI_assert(new_id);
+ }
+ if (new_id) {
+// printf("before remap, old_id users: %d, new_id users: %d\n", old_id->us, new_id->us);
+ BKE_libblock_remap_locked(bmain, old_id, new_id, remap_flags);
+
+ if (old_id->flag & LIB_FAKEUSER) {
+ id_fake_user_clear(old_id);
+ id_fake_user_set(new_id);
+ }
+
+// printf("after remap, old_id users: %d, new_id users: %d\n", old_id->us, new_id->us);
+
+ /* In some cases, new_id might become direct link, remove parent of library in this case. */
+ if (new_id->lib->parent && (new_id->tag & LIB_TAG_INDIRECT) == 0) {
+ if (do_reload) {
+ BLI_assert(0); /* Should not happen in 'pure' reload case... */
+ }
+ new_id->lib->parent = NULL;
+ }
+ }
+
+ if (old_id->us > 0 && new_id && old_id->lib == new_id->lib) {
+ size_t len = strlen(old_id->name);
+
+ /* XXX TODO This is utterly weak!!! */
+ if (len > MAX_ID_NAME - 3 && old_id->name[len - 4] == '.') {
+ old_id->name[len - 6] = '.';
+ old_id->name[len - 5] = 'P';
+ }
+ else {
+ len = MIN2(len, MAX_ID_NAME - 3);
+ old_id->name[len] = '.';
+ old_id->name[len + 1] = 'P';
+ old_id->name[len + 2] = '\0';
+ }
+
+ id_sort_by_name(which_libbase(bmain, GS(old_id->name)), old_id);
+
+ BKE_reportf(reports, RPT_WARNING,
+ "Lib Reload: Replacing all references to old datablock '%s' by reloaded one failed, "
+ "old one (%d remaining users) had to be kept and was renamed to '%s'",
+ new_id->name, old_id->us, old_id->name);
+ }
+ }
+
+ BKE_main_unlock(bmain);
+
+ for (item_idx = 0, itemlink = lapp_data->items.list; itemlink; item_idx++, itemlink = itemlink->next) {
+ WMLinkAppendDataItem *item = itemlink->link;
+ ID *old_id = item->customdata;
+
+ if (old_id->us == 0) {
+ BKE_libblock_free(bmain, old_id);
+ }
+ }
+
+ /* Some datablocks can get reloaded/replaced 'silently' because they are not linkable (shape keys e.g.),
+ * so we need another loop here to clear old ones if possible. */
+ lba_idx = set_listbasepointers(bmain, lbarray);
+ while (lba_idx--) {
+ ID *id, *id_next;
+ for (id = lbarray[lba_idx]->first; id; i
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list