From 2622ebf2fb063c3422ece5b3dc39769e6169724f Mon Sep 17 00:00:00 2001 From: Alex Bilger Date: Wed, 23 Oct 2024 02:34:42 +0200 Subject: [PATCH] Load view only if the file is found (#136) --- SofaGLFW/src/SofaGLFW/SofaGLFWBaseGUI.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/SofaGLFW/src/SofaGLFW/SofaGLFWBaseGUI.cpp b/SofaGLFW/src/SofaGLFW/SofaGLFWBaseGUI.cpp index 98a17f73fd..b144b49a11 100644 --- a/SofaGLFW/src/SofaGLFW/SofaGLFWBaseGUI.cpp +++ b/SofaGLFW/src/SofaGLFW/SofaGLFWBaseGUI.cpp @@ -47,6 +47,7 @@ #include #include #include +#include using namespace sofa; using namespace sofa::gui::common; @@ -213,13 +214,16 @@ void SofaGLFWBaseGUI::restoreCamera(BaseCamera::SPtr camera) if (camera) { const std::string viewFileName = this->getFilename() + std::string(this->getCameraFileExtension()); - if (camera->importParametersFromFile(viewFileName)) + if (helper::system::FileSystem::isFile(viewFileName)) { - msg_info("GUI") << "Current camera parameters have been imported from " << viewFileName << " ."; - } - else - { - msg_error("GUI") << "Could not import camera parameters from " << viewFileName << " ."; + if (camera->importParametersFromFile(viewFileName)) + { + msg_info("GUI") << "Current camera parameters have been imported from " << viewFileName << " ."; + } + else + { + msg_error("GUI") << "Could not import camera parameters from " << viewFileName << " ."; + } } } }