Prevent program crash when unable to open dataset

This commit is contained in:
Erik Broberg
2016-07-07 17:17:12 -04:00
parent 9327a34621
commit 0399795d42
3 changed files with 15 additions and 5 deletions

View File

@@ -210,7 +210,7 @@ namespace openspace {
result->dimensions = glm::uvec3(io.write.region.numPixels, 1);
result->nBytesImageData = io.write.totalNumBytes;
if (_doPreprocessing) {
if (_config.doPreProcessing) {
result->preprocessData = preprocess(result, io.write.region);
result->error = std::max(result->error, postProcessErrorCheck(result, io));
}

View File

@@ -121,7 +121,7 @@ namespace openspace {
//////////////////////////////////////////////////////////////////////////////////
// Initialization //
//////////////////////////////////////////////////////////////////////////////////\
//////////////////////////////////////////////////////////////////////////////////
void initialize();
void ensureInitialized();
@@ -181,8 +181,6 @@ namespace openspace {
TileDepthTransform _depthTransform;
TileDataLayout _dataLayout;
bool _doPreprocessing;
static bool GdalHasBeenInitialized;
bool hasBeenInitialized;
};

View File

@@ -62,7 +62,19 @@ namespace openspace {
LERROR("Unknown type: " << type);
return nullptr;
}
return concreteFactoryIterator->second(desc, initData);
std::shared_ptr<TileProvider> tileProvider;
try {
tileProvider = concreteFactoryIterator->second(desc, initData);
}
catch (const std::exception& e) {
LERROR(e.what());
}
catch (...) {
LERROR("Could not open dataset:\n" << desc << "\n");
}
return tileProvider;
}
void TileProviderFactory::initialize() {