From c64e13ecae143f8c76c8d5ee568aedd858ecbdcd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Mon, 14 Jul 2025 11:43:52 +0200 Subject: [PATCH] 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 --- source/blender/editors/include/UI_grid_view.hh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/source/blender/editors/include/UI_grid_view.hh b/source/blender/editors/include/UI_grid_view.hh index a64a030ef4f..27ce25c92a7 100644 --- a/source/blender/editors/include/UI_grid_view.hh +++ b/source/blender/editors/include/UI_grid_view.hh @@ -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;