Skip to content

Commit

Permalink
Load view only if the file is found (#136)
Browse files Browse the repository at this point in the history
  • Loading branch information
alxbilger authored Oct 23, 2024
1 parent 4373fc0 commit 2622ebf
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions SofaGLFW/src/SofaGLFW/SofaGLFWBaseGUI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
#include <sofa/gui/common/BaseViewer.h>
#include <sofa/gui/common/BaseGUI.h>
#include <sofa/gui/common/PickHandler.h>
#include <sofa/helper/system/FileSystem.h>
using namespace sofa;
using namespace sofa::gui::common;

Expand Down Expand Up @@ -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 << " .";
}
}
}
}
Expand Down

0 comments on commit 2622ebf

Please sign in to comment.