[Bf-blender-cvs] [207df439e1a] master: Cleanup: Use const for internal file data of asset-handle
Julian Eisel
noreply at git.blender.org
Tue Jul 20 21:50:34 CEST 2021
Commit: 207df439e1ad50b3af691f91710b886d0e997993
Author: Julian Eisel
Date: Tue Jul 20 20:06:15 2021 +0200
Branches: master
https://developer.blender.org/rB207df439e1ad50b3af691f91710b886d0e997993
Cleanup: Use const for internal file data of asset-handle
Note that the current asset-handle design is temporary, see
35affaa971cf. I still prefer this to be const, as code outside the
asset-list/file-list code should never mess with the file data of an
asset.
===================================================================
M source/blender/makesdna/DNA_asset_types.h
M source/blender/makesrna/intern/rna_asset.c
M source/blender/makesrna/intern/rna_context.c
===================================================================
diff --git a/source/blender/makesdna/DNA_asset_types.h b/source/blender/makesdna/DNA_asset_types.h
index 3907c158573..8677ec4a50b 100644
--- a/source/blender/makesdna/DNA_asset_types.h
+++ b/source/blender/makesdna/DNA_asset_types.h
@@ -116,7 +116,7 @@ typedef struct AssetLibraryReference {
#
#
typedef struct AssetHandle {
- struct FileDirEntry *file_data;
+ const struct FileDirEntry *file_data;
} AssetHandle;
#ifdef __cplusplus
diff --git a/source/blender/makesrna/intern/rna_asset.c b/source/blender/makesrna/intern/rna_asset.c
index dad35425bda..d13e05c45e9 100644
--- a/source/blender/makesrna/intern/rna_asset.c
+++ b/source/blender/makesrna/intern/rna_asset.c
@@ -129,7 +129,9 @@ static void rna_AssetMetaData_active_tag_range(
static PointerRNA rna_AssetHandle_file_data_get(PointerRNA *ptr)
{
AssetHandle *asset_handle = ptr->data;
- return rna_pointer_inherit_refine(ptr, &RNA_FileSelectEntry, asset_handle->file_data);
+ /* Have to cast away const, but the file entry API doesn't allow modifications anyway. */
+ return rna_pointer_inherit_refine(
+ ptr, &RNA_FileSelectEntry, (FileDirEntry *)asset_handle->file_data);
}
static void rna_AssetHandle_file_data_set(PointerRNA *ptr,
diff --git a/source/blender/makesrna/intern/rna_context.c b/source/blender/makesrna/intern/rna_context.c
index 9da08de2168..70fb10c54b0 100644
--- a/source/blender/makesrna/intern/rna_context.c
+++ b/source/blender/makesrna/intern/rna_context.c
@@ -146,7 +146,9 @@ static PointerRNA rna_Context_asset_file_handle_get(PointerRNA *ptr)
}
PointerRNA newptr;
- RNA_pointer_create(NULL, &RNA_FileSelectEntry, asset_handle.file_data, &newptr);
+ /* Have to cast away const, but the file entry API doesn't allow modifications anyway. */
+ RNA_pointer_create(
+ NULL, &RNA_FileSelectEntry, (struct FileDirEntry *)asset_handle.file_data, &newptr);
return newptr;
}
More information about the Bf-blender-cvs
mailing list