From becd6430ed7dabb24ba136a731f1ee19cab0b69b Mon Sep 17 00:00:00 2001 From: shweet Date: Sun, 22 Nov 2026 19:37:39 -0500 Subject: [PATCH] Find a removed library's layers before the model moves into the flatten Argument order is unspecified: built with clang, the model moved first, no layers were found, and every animation layer was flattened. --- src/edit/content.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/edit/content.cpp b/src/edit/content.cpp index 112e686..83a961a 100644 --- a/src/edit/content.cpp +++ b/src/edit/content.cpp @@ -118,11 +118,13 @@ void content_remove(Model& model, ElementType type, const std::set& ids, in switch (type) { case ElementType::LIBRARY: - model = animation_layers_flatten( - std::move(model), library_get, path_get, - layer_ids_get([&](const Layer& layer) { return ids.contains(layer.libraryId); })); + { + // Found before the model moves into the call. + auto layerIds = layer_ids_get([&](const Layer& layer) { return ids.contains(layer.libraryId); }); + model = animation_layers_flatten(std::move(model), library_get, path_get, layerIds); items_erase(content.libraries); break; + } case ElementType::SPRITESHEET: content_remove(model, ElementType::LAYER_ELEMENT, layer_ids_get([&](const Layer& layer) { return !layer.is_animation() && ids.contains(layer.spritesheetId);