Cleanup: quiet false positive dangling reference warning
I get a warning in a bunch of places where `library_ensure_catalogs_in_path` is called. This is a known false positive of GCC. To workaround the warning, the `AssetCatalogPath` can be constructed in a separate statement to avoid implicitly constructing it as temporary value when calling `library_ensure_catalogs_in_path`. Pull Request: https://projects.blender.org/blender/blender/pulls/136762
This commit is contained in:
@@ -244,22 +244,23 @@ static wmOperatorStatus create_pose_asset_local(bContext *C,
|
||||
BKE_id_rename(*bmain, pose_action.id, name);
|
||||
|
||||
/* Add asset to catalog. */
|
||||
char catalog_path[MAX_NAME];
|
||||
RNA_string_get(op->ptr, "catalog_path", catalog_path);
|
||||
char catalog_path_c[MAX_NAME];
|
||||
RNA_string_get(op->ptr, "catalog_path", catalog_path_c);
|
||||
|
||||
AssetMetaData &meta_data = *pose_action.id.asset_data;
|
||||
asset_system::AssetLibrary *library = AS_asset_library_load(bmain, lib_ref);
|
||||
/* NOTE(@ChrisLend): I don't know if a local library can fail to load.
|
||||
* Just being defensive here. */
|
||||
BLI_assert(library);
|
||||
if (catalog_path[0] && library) {
|
||||
const asset_system::AssetCatalog &catalog = asset::library_ensure_catalogs_in_path(
|
||||
*library, catalog_path);
|
||||
if (catalog_path_c[0] && library) {
|
||||
const asset_system::AssetCatalogPath catalog_path(catalog_path_c);
|
||||
asset_system::AssetCatalog &catalog = asset::library_ensure_catalogs_in_path(*library,
|
||||
catalog_path);
|
||||
BKE_asset_metadata_catalog_id_set(&meta_data, catalog.catalog_id, catalog.simple_name.c_str());
|
||||
}
|
||||
|
||||
ensure_asset_ui_visible(*C);
|
||||
asset::shelf::show_catalog_in_visible_shelves(*C, catalog_path);
|
||||
asset::shelf::show_catalog_in_visible_shelves(*C, catalog_path_c);
|
||||
|
||||
asset::refresh_asset_library(C, lib_ref);
|
||||
|
||||
@@ -303,11 +304,12 @@ static wmOperatorStatus create_pose_asset_user_library(bContext *C,
|
||||
}
|
||||
|
||||
/* Add asset to catalog. */
|
||||
char catalog_path[MAX_NAME];
|
||||
RNA_string_get(op->ptr, "catalog_path", catalog_path);
|
||||
char catalog_path_c[MAX_NAME];
|
||||
RNA_string_get(op->ptr, "catalog_path", catalog_path_c);
|
||||
|
||||
AssetMetaData &meta_data = *pose_action.id.asset_data;
|
||||
if (catalog_path[0]) {
|
||||
if (catalog_path_c[0]) {
|
||||
const asset_system::AssetCatalogPath catalog_path(catalog_path_c);
|
||||
const asset_system::AssetCatalog &catalog = asset::library_ensure_catalogs_in_path(
|
||||
*library, catalog_path);
|
||||
BKE_asset_metadata_catalog_id_set(&meta_data, catalog.catalog_id, catalog.simple_name.c_str());
|
||||
@@ -319,7 +321,7 @@ static wmOperatorStatus create_pose_asset_user_library(bContext *C,
|
||||
|
||||
library->catalog_service().write_to_disk(*final_full_asset_filepath);
|
||||
ensure_asset_ui_visible(*C);
|
||||
asset::shelf::show_catalog_in_visible_shelves(*C, catalog_path);
|
||||
asset::shelf::show_catalog_in_visible_shelves(*C, catalog_path_c);
|
||||
|
||||
BKE_id_free(bmain, &pose_action.id);
|
||||
|
||||
|
||||
@@ -35,13 +35,6 @@ static asset_system::AssetCatalog &library_ensure_catalog(
|
||||
return *library.catalog_service().create_catalog(path);
|
||||
}
|
||||
|
||||
/* Suppress warning for GCC-14.2. This isn't a dangling reference
|
||||
* because the #asset_system::AssetLibrary owns the returned value. */
|
||||
#if defined(__GNUC__) && !defined(__clang__)
|
||||
# pragma GCC diagnostic push
|
||||
# pragma GCC diagnostic ignored "-Wdangling-reference"
|
||||
#endif
|
||||
|
||||
blender::asset_system::AssetCatalog &library_ensure_catalogs_in_path(
|
||||
asset_system::AssetLibrary &library, const blender::asset_system::AssetCatalogPath &path)
|
||||
{
|
||||
@@ -55,10 +48,6 @@ blender::asset_system::AssetCatalog &library_ensure_catalogs_in_path(
|
||||
return *library.catalog_service().find_catalog_by_path(path);
|
||||
}
|
||||
|
||||
#if defined(__GNUC__) && !defined(__clang__)
|
||||
# pragma GCC diagnostic pop
|
||||
#endif
|
||||
|
||||
AssetLibraryReference user_library_to_library_ref(const bUserAssetLibrary &user_library)
|
||||
{
|
||||
AssetLibraryReference library_ref{};
|
||||
|
||||
@@ -149,11 +149,12 @@ static wmOperatorStatus brush_asset_save_as_exec(bContext *C, wmOperator *op)
|
||||
BLI_assert(ID_IS_ASSET(&brush->id));
|
||||
|
||||
/* Add asset to catalog. */
|
||||
char catalog_path[MAX_NAME];
|
||||
RNA_string_get(op->ptr, "catalog_path", catalog_path);
|
||||
char catalog_path_c[MAX_NAME];
|
||||
RNA_string_get(op->ptr, "catalog_path", catalog_path_c);
|
||||
|
||||
AssetMetaData &meta_data = *brush->id.asset_data;
|
||||
if (catalog_path[0]) {
|
||||
if (catalog_path_c[0]) {
|
||||
const asset_system::AssetCatalogPath catalog_path(catalog_path_c);
|
||||
const asset_system::AssetCatalog &catalog = asset::library_ensure_catalogs_in_path(
|
||||
*library, catalog_path);
|
||||
BKE_asset_metadata_catalog_id_set(&meta_data, catalog.catalog_id, catalog.simple_name.c_str());
|
||||
@@ -167,7 +168,7 @@ static wmOperatorStatus brush_asset_save_as_exec(bContext *C, wmOperator *op)
|
||||
}
|
||||
|
||||
library->catalog_service().write_to_disk(*final_full_asset_filepath);
|
||||
asset::shelf::show_catalog_in_visible_shelves(*C, catalog_path);
|
||||
asset::shelf::show_catalog_in_visible_shelves(*C, catalog_path_c);
|
||||
|
||||
brush = reinterpret_cast<Brush *>(
|
||||
bke::asset_edit_id_from_weak_reference(*bmain, ID_BR, brush_asset_reference));
|
||||
@@ -311,8 +312,8 @@ static wmOperatorStatus brush_asset_edit_metadata_exec(bContext *C, wmOperator *
|
||||
}
|
||||
asset_system::AssetLibrary &library = asset->owner_asset_library();
|
||||
|
||||
char catalog_path[MAX_NAME];
|
||||
RNA_string_get(op->ptr, "catalog_path", catalog_path);
|
||||
char catalog_path_c[MAX_NAME];
|
||||
RNA_string_get(op->ptr, "catalog_path", catalog_path_c);
|
||||
|
||||
AssetMetaData &meta_data = *brush->id.asset_data;
|
||||
MEM_SAFE_FREE(meta_data.author);
|
||||
@@ -320,7 +321,8 @@ static wmOperatorStatus brush_asset_edit_metadata_exec(bContext *C, wmOperator *
|
||||
MEM_SAFE_FREE(meta_data.description);
|
||||
meta_data.description = RNA_string_get_alloc(op->ptr, "description", nullptr, 0, nullptr);
|
||||
|
||||
if (catalog_path[0]) {
|
||||
if (catalog_path_c[0]) {
|
||||
const asset_system::AssetCatalogPath catalog_path(catalog_path_c);
|
||||
const asset_system::AssetCatalog &catalog = asset::library_ensure_catalogs_in_path(
|
||||
library, catalog_path);
|
||||
BKE_asset_metadata_catalog_id_set(&meta_data, catalog.catalog_id, catalog.simple_name.c_str());
|
||||
|
||||
Reference in New Issue
Block a user