mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-01-07 04:00:37 -06:00
Fix crash when adding layers through globebrowsing interface due to missing initialization
Fix crash that would happen if the resetting of the tile layer would throw an exception
This commit is contained in:
@@ -84,7 +84,10 @@ int addLayer(lua_State* L) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
globe->layerManager()->addLayer(groupID, d);
|
||||
std::shared_ptr<Layer> layer = globe->layerManager()->addLayer(groupID, d);
|
||||
if (layer) {
|
||||
layer->initialize();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -171,12 +171,16 @@ Layer::Layer(layergroupid::GroupID id, const ghoul::Dictionary& layerDict,
|
||||
}
|
||||
});
|
||||
|
||||
_remove.onChange([&](){
|
||||
if (_tileProvider) {
|
||||
_tileProvider->reset();
|
||||
_remove.onChange([&]() {
|
||||
try {
|
||||
if (_tileProvider) {
|
||||
_tileProvider->reset();
|
||||
}
|
||||
}
|
||||
catch (...) {
|
||||
_parent.deleteLayer(name());
|
||||
throw;
|
||||
}
|
||||
|
||||
_parent.deleteLayer(name());
|
||||
});
|
||||
|
||||
_typeOption.onChange([&](){
|
||||
|
||||
@@ -102,15 +102,17 @@ void LayerGroup::update() {
|
||||
}
|
||||
}
|
||||
|
||||
void LayerGroup::addLayer(const ghoul::Dictionary& layerDict) {
|
||||
std::shared_ptr<Layer> LayerGroup::addLayer(const ghoul::Dictionary& layerDict) {
|
||||
if (!layerDict.hasKeyAndValue<std::string>("Name")) {
|
||||
LERROR("'Name' must be specified for layer.");
|
||||
return;
|
||||
return nullptr;
|
||||
}
|
||||
auto layer = std::make_shared<Layer>(_groupId, layerDict, *this);
|
||||
layer->onChange(_onChangeCallback);
|
||||
if (hasPropertySubOwner(layer->name())) {
|
||||
LINFO("Layer with name " + layer->name() + " already exists.");
|
||||
_levelBlendingEnabled.setVisibility(properties::Property::Visibility::User);
|
||||
return nullptr;
|
||||
}
|
||||
else {
|
||||
_layers.push_back(layer);
|
||||
@@ -119,15 +121,16 @@ void LayerGroup::addLayer(const ghoul::Dictionary& layerDict) {
|
||||
_onChangeCallback();
|
||||
}
|
||||
addPropertySubOwner(layer.get());
|
||||
_levelBlendingEnabled.setVisibility(properties::Property::Visibility::User);
|
||||
return layer;
|
||||
}
|
||||
|
||||
_levelBlendingEnabled.setVisibility(properties::Property::Visibility::User);
|
||||
}
|
||||
|
||||
void LayerGroup::deleteLayer(const std::string& layerName) {
|
||||
for (std::vector<std::shared_ptr<Layer>>::iterator it = _layers.begin(); it != _layers.end(); ++it) {
|
||||
if (it->get()->name() == layerName) {
|
||||
removePropertySubOwner(it->get());
|
||||
(*it)->deinitialize();
|
||||
_layers.erase(it);
|
||||
update();
|
||||
if (_onChangeCallback) {
|
||||
|
||||
@@ -52,7 +52,7 @@ struct LayerGroup : public properties::PropertyOwner {
|
||||
/// Updates all layers tile providers within this group
|
||||
void update();
|
||||
|
||||
void addLayer(const ghoul::Dictionary& layerDict);
|
||||
std::shared_ptr<Layer> addLayer(const ghoul::Dictionary& layerDict);
|
||||
void deleteLayer(const std::string& layerName);
|
||||
|
||||
/// @returns const vector of all layers
|
||||
|
||||
@@ -80,9 +80,11 @@ void LayerManager::deinitialize() {
|
||||
}
|
||||
}
|
||||
|
||||
void LayerManager::addLayer(layergroupid::GroupID groupId, ghoul::Dictionary layerDict) {
|
||||
std::shared_ptr<Layer> LayerManager::addLayer(layergroupid::GroupID groupId,
|
||||
ghoul::Dictionary layerDict)
|
||||
{
|
||||
ghoul_assert(groupId != layergroupid::Unknown, "Layer group ID must be known");
|
||||
_layerGroups[groupId]->addLayer(layerDict);
|
||||
return _layerGroups[groupId]->addLayer(layerDict);
|
||||
}
|
||||
|
||||
void LayerManager::deleteLayer(layergroupid::GroupID groupId, std::string layerName) {
|
||||
|
||||
@@ -48,7 +48,7 @@ public:
|
||||
void initialize();
|
||||
void deinitialize();
|
||||
|
||||
void addLayer(layergroupid::GroupID groupId, ghoul::Dictionary layerDict);
|
||||
std::shared_ptr<Layer> addLayer(layergroupid::GroupID groupId, ghoul::Dictionary layerDict);
|
||||
void deleteLayer(layergroupid::GroupID groupId, std::string layerName);
|
||||
|
||||
const LayerGroup& layerGroup(size_t groupId);
|
||||
|
||||
@@ -78,7 +78,7 @@ std::vector<int> IswaKameleonGroup::fieldlineValue(){
|
||||
}
|
||||
|
||||
void IswaKameleonGroup::setFieldlineInfo(std::string fieldlineIndexFile,
|
||||
std::string kameleonPath
|
||||
std::string kameleonPath)
|
||||
{
|
||||
if (fieldlineIndexFile != _fieldlineIndexFile) {
|
||||
_fieldlineIndexFile = fieldlineIndexFile;
|
||||
|
||||
@@ -679,6 +679,8 @@ void OpenSpaceEngine::loadScene(const std::string& scenePath) {
|
||||
_loadingScreen->render();
|
||||
}
|
||||
|
||||
_windowWrapper->swapBuffer();
|
||||
|
||||
t.join();
|
||||
_loadingScreen = nullptr;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user