diff options
author | Bastien Montagne <bastien@blender.org> | 2022-04-29 17:52:59 +0300 |
---|---|---|
committer | Bastien Montagne <bastien@blender.org> | 2022-04-29 18:57:46 +0300 |
commit | 3c7a6718ddc52fbf2a6a8d57822007738699fe96 (patch) | |
tree | 2181ba80c896ea19625d8af43431ee137d2a02e3 /source/blender/blenkernel/BKE_lib_principle_properties.h | |
parent | 4d464a946a061cdcd6bca3b7d41de01eb3fc33d6 (diff) |
Fix T95480: Crash when relocating libraries in some cases.
While code deleting old (relocated to new ones) IDs would work fine in
typical cases, it would fail badly in others, when e.g. drivers would
create 'reversed' dependency from the obdata ID to the object ID.
This commit uses a less efficient, but much safer method. It also
ensures no relocated old IDs is left over in the file (previous version
could easily leave some old IDs from the old library until a full
save/reload cycle happened).
Diffstat (limited to 'source/blender/blenkernel/BKE_lib_principle_properties.h')
-rw-r--r-- | source/blender/blenkernel/BKE_lib_principle_properties.h | 85 |
1 files changed, 85 insertions, 0 deletions
diff --git a/source/blender/blenkernel/BKE_lib_principle_properties.h b/source/blender/blenkernel/BKE_lib_principle_properties.h new file mode 100644 index 00000000000..10d0d33a0c4 --- /dev/null +++ b/source/blender/blenkernel/BKE_lib_principle_properties.h @@ -0,0 +1,85 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later + * Copyright 2022 Blender Foundation. All rights reserved. */ + +#pragma once + +/** \file + * \ingroup bke + * + * API to manage principle properties in data-blocks. + * + * Principle properties are properties that are defined as the ones most user will need to + * edit when using this data-block. + * + * They current main usage in is library overrides. + * + * \note `BKE_lib_` files are for operations over data-blocks themselves, although they might + * alter Main as well (when creating/renaming/deleting an ID e.g.). + * + * \section Function Names + * + * - `BKE_lib_principleprop_` should be used for function affecting a single ID. + * - `BKE_lib_principleprop_main_` should be used for function affecting the whole collection + * of IDs in a given Main data-base. + */ + +#ifdef __cplusplus +extern "C" { +#endif + +struct ID; +struct IDPrincipleProperties; +struct IDPrincipleProperty; +struct PointerRNA; +struct PropertyRNA; +struct ReportList; + +/** + * Initialize empty list of principle properties for \a id. + */ +struct IDPrincipleProperties *BKE_lib_principleprop_init(struct ID *id); +#if 0 +/** + * Shallow or deep copy of a whole princple properties from \a src_id to \a dst_id. + */ +void BKE_lib_principleprop_copy(struct ID *dst_id, const struct ID *src_id, bool do_full_copy); +#endif +/** + * Clear any principle properties data from given \a override. + */ +void BKE_lib_principleprop_clear(struct IDPrincipleProperties *principle_props, bool do_id_user); +/** + * Free given \a principle_props. + */ +void BKE_lib_principleprop_free(struct IDPrincipleProperties **principle_props, bool do_id_user); + +/** + * Find principle property from given RNA path, if it exists. + */ +struct IDPrincipleProperty *BKE_lib_principleprop_find( + struct IDPrincipleProperties *principle_props, const char *rna_path); +/** + * Find principle property from given RNA path, or create it if it does not exist. + */ +struct IDPrincipleProperty *BKE_lib_principleprop_get( + struct IDPrincipleProperties *principle_props, const char *rna_path, bool *r_created); +/** + * Remove and free given \a principle_prop from given ID \a principle_props. + */ +void BKE_lib_principleprop_delete(struct IDPrincipleProperties *principle_props, + struct IDPrincipleProperty *principle_prop); +/** + * Get the RNA-property matching the \a principle_prop principle property. Used for UI to query + * additional data about the principle property (e.g. UI name). + * + * \param idpoin: RNA Pointer of the ID. + * \param principle_prop: The principle property to find the matching RNA property for. + */ +bool BKE_lib_principleprop_rna_property_find(struct PointerRNA *idpoin, + const struct IDPrincipleProperty *principle_prop, + struct PointerRNA *r_principle_poin, + struct PropertyRNA **r_principle_prop); + +#ifdef __cplusplus +} +#endif |