[Bf-blender-cvs] [7dea5c2] asset-engine: Finish implementing 'reports' in asset engine (not used yet).
Bastien Montagne
noreply at git.blender.org
Thu Apr 7 16:36:36 CEST 2016
Commit: 7dea5c2462bd9e8cc2fa806ef15063c8b7368fa2
Author: Bastien Montagne
Date: Thu Apr 7 16:18:42 2016 +0200
Branches: asset-engine
https://developer.blender.org/rB7dea5c2462bd9e8cc2fa806ef15063c8b7368fa2
Finish implementing 'reports' in asset engine (not used yet).
===================================================================
M source/blender/blenkernel/BKE_asset.h
M source/blender/blenkernel/intern/asset.c
M source/blender/blenkernel/intern/blender.c
M source/blender/editors/space_file/filelist.c
M source/blender/makesrna/intern/rna_asset.c
===================================================================
diff --git a/source/blender/blenkernel/BKE_asset.h b/source/blender/blenkernel/BKE_asset.h
index 5980084..5a2319d 100644
--- a/source/blender/blenkernel/BKE_asset.h
+++ b/source/blender/blenkernel/BKE_asset.h
@@ -49,6 +49,7 @@ struct ExtensionRNA;
struct ID;
struct IDProperty;
struct ListBase;
+struct ReportList;
struct uiLayout;
enum {
@@ -186,7 +187,7 @@ AssetEngineType *BKE_asset_engines_find(const char *idname);
AssetEngineType *BKE_asset_engines_get_default(char *r_idname, const size_t len);
/* Engine Instances */
-AssetEngine *BKE_asset_engine_create(AssetEngineType *type);
+AssetEngine *BKE_asset_engine_create(AssetEngineType *type, struct ReportList *reports);
AssetEngine *BKE_asset_engine_copy(AssetEngine *engine);
void BKE_asset_engine_free(AssetEngine *engine);
diff --git a/source/blender/blenkernel/intern/asset.c b/source/blender/blenkernel/intern/asset.c
index e2bc0d6..0fb85a8 100644
--- a/source/blender/blenkernel/intern/asset.c
+++ b/source/blender/blenkernel/intern/asset.c
@@ -117,7 +117,7 @@ AssetEngineType *BKE_asset_engines_get_default(char *r_idname, const size_t len)
/* Create, Free */
-AssetEngine *BKE_asset_engine_create(AssetEngineType *type)
+AssetEngine *BKE_asset_engine_create(AssetEngineType *type, ReportList *reports)
{
AssetEngine *engine;
@@ -127,6 +127,15 @@ AssetEngine *BKE_asset_engine_create(AssetEngineType *type)
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;
}
@@ -151,6 +160,11 @@ void BKE_asset_engine_free(AssetEngine *engine)
MEM_freeN(engine->properties);
}
+ if (engine->reports && (engine->reports->flag & RPT_FREE)) {
+ BKE_reports_clear(engine->reports);
+ MEM_freeN(engine->reports);
+ }
+
MEM_freeN(engine);
}
}
diff --git a/source/blender/blenkernel/intern/blender.c b/source/blender/blenkernel/intern/blender.c
index 36f6f63..a2f2636 100644
--- a/source/blender/blenkernel/intern/blender.c
+++ b/source/blender/blenkernel/intern/blender.c
@@ -544,7 +544,7 @@ static void read_file_update_assets(bContext *C)
printf("ERROR! Unknown asset engine!\n");
}
else {
- ae = BKE_asset_engine_create(ae_type);
+ ae = BKE_asset_engine_create(ae_type, NULL);
}
/* Note: we assume update check callback does not add, remove or alter order of uuids in that list! */
diff --git a/source/blender/editors/space_file/filelist.c b/source/blender/editors/space_file/filelist.c
index fa69dee..90f7224 100644
--- a/source/blender/editors/space_file/filelist.c
+++ b/source/blender/editors/space_file/filelist.c
@@ -1454,7 +1454,7 @@ void filelist_assetengine_set(struct FileList *filelist, struct AssetEngineType
}
if (aet) {
- filelist->ae = BKE_asset_engine_create(aet);
+ filelist->ae = BKE_asset_engine_create(aet, NULL);
}
filelist->flags |= FL_FORCE_RESET;
}
diff --git a/source/blender/makesrna/intern/rna_asset.c b/source/blender/makesrna/intern/rna_asset.c
index 7dd44f1..42419c6 100644
--- a/source/blender/makesrna/intern/rna_asset.c
+++ b/source/blender/makesrna/intern/rna_asset.c
@@ -305,6 +305,13 @@ static void rna_AssetList_entries_clear(FileDirEntryArr *dirlist)
BKE_filedir_entryarr_clear(dirlist);
}
+/* AssetEngine API. */
+
+static void rna_ae_report(AssetEngine *engine, int type, const char *msg)
+{
+ BKE_report(engine->reports, type, msg);
+}
+
/* AssetEngine callbacks. */
static int rna_ae_status(AssetEngine *engine, const int id)
@@ -438,7 +445,6 @@ static void rna_ae_check_dir(AssetEngine *engine, char *r_dir)
{
extern FunctionRNA rna_AssetEngine_check_dir_func;
PointerRNA ptr;
- PropertyRNA *parm;
ParameterList list;
FunctionRNA *func;
@@ -1079,6 +1085,16 @@ static void rna_def_asset_engine(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Dirty Filtering", "FileBrowser shall call AE's filtering function on next draw");
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_FILE_PARAMS, NULL);
+ /* Utilities, not for registering. */
+ func = RNA_def_function(srna, "report", "rna_ae_report");
+ RNA_def_function_ui_description(func, "Generate a report (error, info, warning, etc.)");
+ parm = RNA_def_enum_flag(func, "type", rna_enum_wm_report_items, 0, "", "");
+ RNA_def_property_flag(parm, PROP_REQUIRED);
+ parm = RNA_def_string(func, "message", NULL, 0, "", "");
+ RNA_def_property_flag(parm, PROP_REQUIRED);
+
+ /* API */
+
/* Status callback */
func = RNA_def_function(srna, "status", NULL);
RNA_def_function_ui_description(func, "Get status of whole engine, or a given job");
More information about the Bf-blender-cvs
mailing list