Various UI code would store the `AssetHandle` in a way that turns out to be unsafe. The file-data is part of the file browser caching system that releases file-data when a certain maximum of items is in the cache. So even while just iterating over the assets, earlier iterated asset handles may become invalid. Now asset handles are really treated as volatile, short lived objects. For the asset-view, the fix was more involved. There we need an RNA collection of asset-handles, because the UI list code requires that. So we create a dummy collection and get the asset handles as needed by index. This again meant that I had to keep the index of the collection and the asset-list in sync, so all filtering had to be moved to the UI list. I tried duplicating the file-data out of the cache instead, but that caused problems with managing the memory/ownership of the preview images. `AssetHandle` should be removed and replaced by `AssetRepresentation`, but this would be an even more disruptive change (breaking API compatibility too). Fixes #104305, #105535. Pull Request: #105773
24 lines
389 B
C++
24 lines
389 B
C++
/* SPDX-License-Identifier: GPL-2.0-or-later */
|
|
|
|
/** \file
|
|
* \ingroup edasset
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include "DNA_ID_enums.h"
|
|
|
|
struct AssetRepresentation;
|
|
struct Main;
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
struct ID *ED_asset_get_local_id_from_asset_or_append_and_reuse(
|
|
struct Main *bmain, const struct AssetRepresentation *asset_c_ptr, ID_Type idtype);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|