UntoldEngine icon indicating copy to clipboard operation
UntoldEngine copied to clipboard

Issue with pushing and popping layers.

Open untoldengine opened this issue 4 years ago • 2 comments

Popping a layer does not remove it from the vector container. I need to rethink this. It seems I'm doing double work. One, the layer is stored in a vector container, and then to be displayed, it is pushed into the stack. I'm sure there was a good reason for this, but this is causing the layers popped to be left in the vector container. So, I either bypass the "addLayerToContainer" method and push it directly into the stack, or when popping the stack, I also remove the layer from the container.

Possible fix that can be included in the pop method.

This will remove the layer from the vector container

layerContainer.erase(std::remove_if(layerContainer.begin(), layerContainer.end(),[topLayer](U4DLayer *e){ return (e==topLayer);} ),layerContainer.end());

untoldengine avatar May 13 '21 22:05 untoldengine

You should also test if the layer exists in the container before inserting it.

untoldengine avatar May 13 '21 22:05 untoldengine

Should write this in the documentation of how to use layers. The layers should first be initialized and added into the container using the method addLayerToContainer(). Once they are added, the layers can be referenced and pushed into the layer stack by referring to the layer's name.

untoldengine avatar May 14 '21 21:05 untoldengine