mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-01-05 19:19:39 -06:00
Instead of deleting layers directly through the property, schedule them to delete in the next frame instead (closes #3357)
This commit is contained in:
@@ -26,6 +26,8 @@
|
||||
|
||||
#include <openspace/documentation/documentation.h>
|
||||
#include <openspace/documentation/verifier.h>
|
||||
#include <openspace/engine/globals.h>
|
||||
#include <openspace/scripting/scriptengine.h>
|
||||
#include <modules/globebrowsing/src/layergroup.h>
|
||||
#include <modules/globebrowsing/src/layermanager.h>
|
||||
#include <modules/globebrowsing/src/tileindex.h>
|
||||
@@ -320,7 +322,7 @@ Layer::Layer(layers::Group::ID id, const ghoul::Dictionary& layerDict, LayerGrou
|
||||
_remove.onChange([this]() {
|
||||
if (_tileProvider) {
|
||||
_tileProvider->reset();
|
||||
_parent.deleteLayer(identifier());
|
||||
_parent.scheduleDeleteLayer(identifier());
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -89,6 +89,11 @@ void LayerGroup::deinitialize() {
|
||||
void LayerGroup::update() {
|
||||
ZoneScoped;
|
||||
|
||||
for (const std::string& layer : _layersToDelete) {
|
||||
deleteLayer(layer);
|
||||
}
|
||||
_layersToDelete.clear();
|
||||
|
||||
_activeLayers.clear();
|
||||
|
||||
for (const std::unique_ptr<Layer>& layer : _layers) {
|
||||
@@ -217,6 +222,10 @@ void LayerGroup::deleteLayer(const std::string& layerName) {
|
||||
LERROR("Could not find layer " + layerName);
|
||||
}
|
||||
|
||||
void LayerGroup::scheduleDeleteLayer(const std::string& layerName) {
|
||||
_layersToDelete.push_back(layerName);
|
||||
}
|
||||
|
||||
void LayerGroup::moveLayer(int oldPosition, int newPosition) {
|
||||
if (_layers.size() == 1) {
|
||||
ghoul_assert(
|
||||
|
||||
@@ -53,6 +53,9 @@ struct LayerGroup : public properties::PropertyOwner {
|
||||
|
||||
Layer* addLayer(const ghoul::Dictionary& layerDict);
|
||||
void deleteLayer(const std::string& layerName);
|
||||
|
||||
// The same as `deleteLayer` but executed later before the next frame
|
||||
void scheduleDeleteLayer(const std::string& layerName);
|
||||
void moveLayer(int oldPosition, int newPosition);
|
||||
|
||||
/**
|
||||
@@ -81,6 +84,8 @@ private:
|
||||
std::vector<std::unique_ptr<Layer>> _layers;
|
||||
std::vector<Layer*> _activeLayers;
|
||||
|
||||
std::vector<std::string> _layersToDelete;
|
||||
|
||||
properties::BoolProperty _levelBlendingEnabled;
|
||||
std::function<void(Layer*)> _onChangeCallback;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user