[Bf-blender-cvs] [75534245119] asset-engine: Merge branch 'master' into asset-engine
Bastien Montagne
noreply at git.blender.org
Thu May 23 21:35:14 CEST 2019
Commit: 7553424511920e77474566088a7f04e8a56723cd
Author: Bastien Montagne
Date: Thu May 23 21:12:09 2019 +0200
Branches: asset-engine
https://developer.blender.org/rB7553424511920e77474566088a7f04e8a56723cd
Merge branch 'master' into asset-engine
Conflicts:
source/blender/blenkernel/intern/library.c
source/blender/blenkernel/intern/library_remap.c
source/blender/blenloader/intern/readfile.c
source/blender/blenloader/intern/versioning_defaults.c
source/blender/editors/space_file/space_file.c
source/blender/makesdna/DNA_space_types.h
source/blender/windowmanager/WM_api.h
source/blender/windowmanager/intern/wm_files_link.c
source/blender/windowmanager/intern/wm_init_exit.c
===================================================================
===================================================================
diff --cc release/scripts/startup/bl_ui/space_info.py
index c22c480674d,a8aa0d9d0b6..44414cb3cc5
--- a/release/scripts/startup/bl_ui/space_info.py
+++ b/release/scripts/startup/bl_ui/space_info.py
@@@ -28,19 -28,7 +28,18 @@@ class INFO_HT_header(Header)
layout.template_header()
# Empty for now until info editor gets turned into log editor
- pass
+"""
+ if (bpy.app.assets_fail or bpy.app.assets_need_reload) and not bpy.app.assets_quiet:
+ row.operator("script.assets_warn_clear", text="Ignore")
+ if bpy.app.assets_need_reload is True and bpy.app.assets_quiet is False:
+ row.operator("wm.assets_reload", icon='SCREEN_BACK', text="Reload Assets")
+ row.label("Some assets have to be reloaded", icon='INFO')
+ if bpy.app.assets_fail is True and bpy.app.assets_quiet is False:
+ row.label("Some asset engine(s) failed to retrieve updated data about their assets...", icon='ERROR')
+ return
+"""
+
# Not really info, just add to re-usable location.
class INFO_MT_area(Menu):
diff --cc source/blender/blenkernel/BKE_global.h
index 92b12efc4a7,9fe8fc3880f..63253ea001a
--- a/source/blender/blenkernel/BKE_global.h
+++ b/source/blender/blenkernel/BKE_global.h
@@@ -110,12 -110,8 +110,12 @@@ enum
G_FLAG_PICKSEL = (1 << 2),
/** Support simulating events (for testing). */
G_FLAG_EVENT_SIMULATE = (1 << 3),
+ G_FLAG_USERPREF_NO_SAVE_ON_EXIT = (1 << 4),
+ G_ASSETS_NEED_RELOAD = (1 << 10),
+ G_ASSETS_FAIL = (1 << 11),
+ G_ASSETS_QUIET = (1 << 12),
+
G_FLAG_SCRIPT_AUTOEXEC = (1 << 13),
/** When this flag is set ignore the prefs #USER_SCRIPT_AUTOEXEC_DISABLE. */
G_FLAG_SCRIPT_OVERRIDE_PREF = (1 << 14),
diff --cc source/blender/blenkernel/intern/asset_engine.c
index bd3ddaaed80,00000000000..4ac44324b6d
mode 100644,000000..100644
--- a/source/blender/blenkernel/intern/asset_engine.c
+++ b/source/blender/blenkernel/intern/asset_engine.c
@@@ -1,504 -1,0 +1,505 @@@
+/*
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2015 Blender Foundation.
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): none yet.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file blender/blenkernel/intern/asset_engine.c
+ * \ingroup bke
+ */
+
+#include <stddef.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "MEM_guardedalloc.h"
+
+#include "RNA_access.h"
+#include "RNA_types.h"
+
+#include "BLT_translation.h"
+
+#include "BLI_fileops_types.h"
+#include "BLI_hash_mm2a.h"
+#include "BLI_listbase.h"
+#include "BLI_string.h"
+#include "BLI_utildefines.h"
+
+#include "PIL_time.h"
+
+#include "BKE_asset_engine.h"
+#include "BKE_global.h"
+#include "BKE_idprop.h"
+#include "BKE_library.h"
+#include "BKE_main.h"
+#include "BKE_report.h"
+
+#include "IMB_imbuf.h"
+
+#include "DNA_space_types.h"
+
+#ifdef WITH_PYTHON
+# include "BPY_extern.h"
+#endif
+
+/* Asset engine types (none intern!). */
+
+ListBase asset_engines = {NULL, NULL};
+
+void BKE_asset_engines_init(void)
+{
+ /* We just add a dummy engine, which 'is' our intern filelisting code from space_file! */
+ AssetEngineType *aet = MEM_callocN(sizeof(*aet), __func__);
+
+ BLI_strncpy(aet->idname, AE_FAKE_ENGINE_ID, sizeof(aet->idname));
+ BLI_strncpy(aet->name, "None", sizeof(aet->name));
+
+ BLI_addhead(&asset_engines, aet);
+}
+
+void BKE_asset_engines_exit(void)
+{
+ AssetEngineType *type, *next;
+
+ for (type = asset_engines.first; type; type = next) {
+ next = type->next;
+
+ BLI_remlink(&asset_engines, type);
+
+ if (type->ext.free) {
+ type->ext.free(type->ext.data);
+ }
+
+ MEM_freeN(type);
+ }
+}
+
+AssetEngineType *BKE_asset_engines_find(const char *idname)
+{
+ AssetEngineType *type;
+
+ type = BLI_findstring(&asset_engines, idname, offsetof(AssetEngineType, idname));
+
+ return type;
+}
+
+AssetEngineType *BKE_asset_engines_get_default(char *r_idname, const size_t len)
+{
+ AssetEngineType *type = asset_engines.first;
+
+ BLI_assert(type);
+
+ if (r_idname) {
+ BLI_strncpy(r_idname, type->idname, len);
+ }
+
+ return type;
+}
+
+/* Asset engine instances. */
+
+/* Create, Free */
+
+AssetEngine *BKE_asset_engine_create(AssetEngineType *type, ReportList *reports)
+{
+ AssetEngine *engine;
+
+ BLI_assert(type);
+
+ engine = MEM_callocN(sizeof(AssetEngine), __func__);
+ engine->type = type;
+ engine->refcount = 1;
+
+ /* initialize error reports */
+ if (reports) {
+ engine->reports = reports; /* must be initialized already */
+ }
+ else {
+ engine->reports = MEM_mallocN(sizeof(ReportList), __func__);
+ BKE_reports_init(engine->reports, RPT_STORE | RPT_FREE);
+ }
+
+ return engine;
+}
+
+/** Shalow copy only (i.e. memory is 100% shared, just increases refcount). */
+AssetEngine *BKE_asset_engine_copy(AssetEngine *engine)
+{
+ engine->refcount++;
+ return engine;
+}
+
+void BKE_asset_engine_free(AssetEngine *engine)
+{
+ if (engine->refcount-- == 1) {
+#ifdef WITH_PYTHON
+ if (engine->py_instance) {
+ BPY_DECREF_RNA_INVALIDATE(engine->py_instance);
+ }
+#endif
+
+ if (engine->properties) {
+ IDP_FreeProperty(engine->properties);
- MEM_freeN(engine->properties);
+ }
+
+ if (engine->reports && (engine->reports->flag & RPT_FREE)) {
+ BKE_reports_clear(engine->reports);
+ MEM_freeN(engine->reports);
+ }
+
+ MEM_freeN(engine);
+ }
+}
+
+/* API helpers. */
+
+static void asset_engine_load_pre(AssetEngine *engine,
+ AssetUUIDList *r_uuids,
+ FileDirEntryArr *r_entries)
+{
+ FileDirEntry *en;
+ AssetUUID *uuid;
+ const int nbr_entries = r_entries->nbr_entries ? r_entries->nbr_entries : r_uuids->nbr_uuids;
+
+ if (r_entries->nbr_entries) {
+ BLI_assert(r_uuids->uuids == NULL);
+ r_uuids->uuids = MEM_callocN(sizeof(*r_uuids->uuids) * nbr_entries, __func__);
+ r_uuids->nbr_uuids = nbr_entries;
+ r_uuids->asset_engine_version = engine->type->version;
+
+ for (en = r_entries->entries.first, uuid = r_uuids->uuids; en; en = en->next, uuid++) {
+ memcpy(uuid->uuid_repository, en->uuid_repository, sizeof(uuid->uuid_repository));
+
+ memcpy(uuid->uuid_asset, en->uuid, sizeof(uuid->uuid_asset));
+
+ FileDirEntryVariant *var = BLI_findlink(&en->variants, en->act_variant);
+ BLI_assert(var);
+ memcpy(uuid->uuid_variant, var->uuid, sizeof(uuid->uuid_variant));
+
+ FileDirEntryRevision *rev = BLI_findlink(&var->revisions, var->act_revision);
+ BLI_assert(rev);
+ memcpy(uuid->uuid_revision, rev->uuid, sizeof(uuid->uuid_revision));
+
+ memcpy(uuid->uuid_view, en->entry->uuid, sizeof(uuid->uuid_view));
+ }
+ }
+
+ BKE_filedir_entryarr_clear(r_entries);
+
+ if (!engine->type->load_pre(engine, r_uuids, r_entries)) {
+ /* If load_pre returns false (i.e. fails), clear all paths! */
+ /* TODO: report!!! */
+ BKE_filedir_entryarr_clear(r_entries);
+
+ MEM_freeN(r_uuids->uuids);
+ r_uuids->uuids = NULL;
+ r_uuids->nbr_uuids = 0;
+ return;
+ }
+
+ /* load_pre may change things, we have to rebuild our uuids list from returned entries. */
+ r_entries->nbr_entries = r_uuids->nbr_uuids = BLI_listbase_count(&r_entries->entries);
+ r_uuids->uuids = MEM_reallocN(r_uuids->uuids, sizeof(*r_uuids->uuids) * r_uuids->nbr_uuids);
+ for (en = r_entries->entries.first, uuid = r_uuids->uuids; en; en = en->next, uuid++) {
+ FileDirEntryVariant *var;
+ FileDirEntryRevision *rev;
+ FileDirEntryView *view;
+
+ memcpy(uuid->uuid_repository, en->uuid_repository, sizeof(uuid->uuid_repository));
+
+ memcpy(uuid->uuid_asset, en->uuid, sizeof(uuid->uuid_asset));
+
+ var = BLI_findlink(&en->variants, en->act_variant);
+ BLI_assert(var);
+ memcpy(uuid->uuid_variant, var->uuid, sizeof(uuid->uuid_variant));
+
+ rev = BLI_findlink(&var->revisions, var->act_revision);
+ BLI_assert(rev);
+ memcpy(uuid->uuid_revision, rev->uuid, sizeof(uuid->uuid_revision));
+
+ view = BLI_findlink(&rev->views, rev->act_view);
+ BLI_assert(view);
+ memcpy(uuid->uuid_view, view->uuid, sizeof(uuid->uuid_view));
+ }
+}
+
+/** Call load_pre for given entries, and return new uuids/entries. */
+AssetUUIDList *BKE_asset_engine_entries_load_pre(AssetEngine *engine, FileDirEntryArr *r_entries)
+{
+ AssetUUIDList *uuids = MEM_callocN(sizeof(*uuids), __func__);
+
+ asset_engine_load_pre(engine, uuids, r_entries);
+
+ return uuids;
+}
+
+/** Call load_pre for given uuids, and return new uuids/entries. */
+FileDirEntryArr *BKE_asset_engine_uuids_load_pre(AssetEngine *engine, AssetUUIDList *r_uuids)
+{
+ FileDirEntryArr *entries = MEM_callocN(sizeof(*entries), __func__);
+
+ asset_engine_load_pre(engine, r_uuids, entries);
+
+ return entries;
+}
+
+/* FileDirxxx handling. */
+
+void BKE_filedir_view_free(FileDirEntryView *view)
+{
+ if (view->name) {
+ MEM_freeN(view->name);
+ }
+ if (view->description) {
+ MEM_freeN(view->description);
+ }
+ MEM_freeN(view);
+}
+
+void BKE_filedir_revision_free(FileDirEntryRevision *rev)
+{
+ if (rev->comment) {
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list