diff --git a/application/F3DStarter.cxx b/application/F3DStarter.cxx index 3995f1cd4d..b72c5509e7 100644 --- a/application/F3DStarter.cxx +++ b/application/F3DStarter.cxx @@ -936,29 +936,52 @@ int F3DStarter::Start(int argc, char** argv) bool offscreen = !this->Internals->AppOptions.Reference.empty() || !this->Internals->AppOptions.Output.empty() || this->Internals->AppOptions.BindingsList; - if (this->Internals->AppOptions.RenderingBackend == "egl") + try { - this->Internals->Engine = std::make_unique(f3d::engine::createEGL()); + if (this->Internals->AppOptions.RenderingBackend == "egl") + { + this->Internals->Engine = std::make_unique(f3d::engine::createEGL()); + } + else if (this->Internals->AppOptions.RenderingBackend == "osmesa") + { + this->Internals->Engine = std::make_unique(f3d::engine::createOSMesa()); + } + else if (this->Internals->AppOptions.RenderingBackend == "glx") + { + this->Internals->Engine = std::make_unique(f3d::engine::createGLX(offscreen)); + } + else if (this->Internals->AppOptions.RenderingBackend == "wgl") + { + this->Internals->Engine = std::make_unique(f3d::engine::createWGL(offscreen)); + } + else + { + if (this->Internals->AppOptions.RenderingBackend != "auto") + { + f3d::log::warn("--rendering-backend value is invalid, falling back to \"auto\""); + } + this->Internals->Engine = std::make_unique(f3d::engine::create(offscreen)); + } } - else if (this->Internals->AppOptions.RenderingBackend == "osmesa") + catch (const f3d::context::loading_exception& ex) { - this->Internals->Engine = std::make_unique(f3d::engine::createOSMesa()); + f3d::log::error("Could not load graphic library: ", ex.what()); + return EXIT_FAILURE; } - else if (this->Internals->AppOptions.RenderingBackend == "glx") + catch (const f3d::context::symbol_exception& ex) { - this->Internals->Engine = std::make_unique(f3d::engine::createGLX(offscreen)); + f3d::log::error("Could not find needed symbol in graphic library: ", ex.what()); + return EXIT_FAILURE; } - else if (this->Internals->AppOptions.RenderingBackend == "wgl") + catch (const f3d::engine::no_window_exception& ex) { - this->Internals->Engine = std::make_unique(f3d::engine::createWGL(offscreen)); + f3d::log::error("Could not create the window: ", ex.what()); + return EXIT_FAILURE; } - else + catch (const f3d::engine::cache_exception& ex) { - if (this->Internals->AppOptions.RenderingBackend != "auto") - { - f3d::log::warn("--rendering-backend value is invalid, falling back to \"auto\""); - } - this->Internals->Engine = std::make_unique(f3d::engine::create(offscreen)); + f3d::log::error("Could not use default cache directory: ", ex.what()); + return EXIT_FAILURE; } this->ResetWindowName(); diff --git a/application/testing/CMakeLists.txt b/application/testing/CMakeLists.txt index 55f8fec39a..df948e74a2 100644 --- a/application/testing/CMakeLists.txt +++ b/application/testing/CMakeLists.txt @@ -1187,6 +1187,8 @@ set_tests_properties(f3d::TestNoFileFileNameTemplate PROPERTIES PASS_REGULAR_EXP set_tests_properties(f3d::TestNoFileFileNameTemplate PROPERTIES ENVIRONMENT "CTEST_F3D_NO_DATA_FORCE_RENDER=1") if(NOT WIN32) + f3d_test(NAME TestInvalidCache ENV "HOME=" REGEXP "Could not use default cache directory" NO_BASELINE) + add_test(NAME f3d::TestHOMEOutput COMMAND $ ${F3D_SOURCE_DIR}/testing/data/suzanne.stl --output=~/Testing/Temporary/TestHOMEOutput.png --resolution=300,300 --no-config) set_tests_properties(f3d::TestHOMEOutput PROPERTIES ENVIRONMENT "HOME=${CMAKE_BINARY_DIR}") set_tests_properties(f3d::TestHOMEOutput PROPERTIES FIXTURES_SETUP f3d::TestHOMEOutput_FIXTURE) diff --git a/library/src/engine.cxx b/library/src/engine.cxx index 3557b0bc38..8d106273c5 100644 --- a/library/src/engine.cxx +++ b/library/src/engine.cxx @@ -85,6 +85,7 @@ engine::engine( #endif if (cachePath.empty()) { + delete Internals; throw engine::cache_exception( "Could not setup cache, please set the appropriate environment variable"); }