Prevent crash when accessing a layer name after it has been deleted (closes #3283)

This commit is contained in:
Alexander Bock
2024-05-27 14:00:31 +02:00
parent be6c3f801e
commit ff9b72c580
+4 -1
View File
@@ -177,12 +177,15 @@ void LayerGroup::deleteLayer(const std::string& layerName) {
layerGroup->identifier(),
it->get()->identifier()
);
// We need to keep the name of the layer since we only get it as a reference
// and the name needs to survive the deletion
const std::string lName = layerName;
_layers.erase(it);
update();
if (_onChangeCallback) {
_onChangeCallback(nullptr);
}
LINFO("Deleted layer " + layerName);
LINFO(std::format("Deleted layer {}", lName));
if (_layers.empty()) {
_levelBlendingEnabled.setVisibility(