Fix #141882: Undo with local asset in asset shelf crashes Blender (ASAN)

Replace a `StringRef` with `std::string`, so that a copy is made of the
grid item identifier.

This identifier is used on redraw, to correlate the newly-drawn items
with items from the previous redraw. Using a `StringRef` here was
problematic when there's local assets, as those can be freed & re-built
(which in the case of the report happens on save/undo). Because of this,
the reference got corrupted, and the map lookup would fail. The "old
items" map now has a copy of the identifier, ensuring it is independent
of the data it represents.

Co-authored by Julian Eisel.

Pull Request: https://projects.blender.org/blender/blender/pulls/141888
This commit is contained in:
Sybren A. Stüvel
2025-07-14 11:43:52 +02:00
parent d5fcf4dee5
commit c64e13ecae

View File

@@ -39,8 +39,12 @@ class AbstractGridViewItem : public AbstractViewItem {
friend class GridViewLayoutBuilder;
protected:
/** Reference to a string that uniquely identifies this item in the view. */
StringRef identifier_{};
/**
* A string that uniquely identifies this item in the view.
*
* Ideally this would just be a StringRef to save memory. This was made a
* std::string to fix #141882 in a relatively safe way. */
std::string identifier_{};
public:
/* virtual */ ~AbstractGridViewItem() override = default;