Skip to content

Commit

Permalink
PR #13680 from remibettan: avoid viewer exception when creating new d…
Browse files Browse the repository at this point in the history
…evice_model fails
  • Loading branch information
Nir-Az authored Jan 13, 2025
2 parents d40c2e2 + 667e737 commit 3aebaf9
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion tools/realsense-viewer/realsense-viewer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,21 @@ bool refresh_devices(std::mutex& m,
if (device_models.size() == 0 &&
dev.supports(RS2_CAMERA_INFO_NAME) && std::string(dev.get_info(RS2_CAMERA_INFO_NAME)) != "Platform Camera" && std::string(dev.get_info(RS2_CAMERA_INFO_NAME)).find("IP Device") == std::string::npos)
{
device_models.emplace_back(new device_model(dev, error_message, viewer_model));
try
{
device_models.emplace_back(new device_model(dev, error_message, viewer_model));
}
catch (const std::exception& e)
{
log(RS2_LOG_SEVERITY_ERROR, "Exception raised on device_model creation");
auto dev_name_itr = std::find(begin(device_names), end(device_names), get_device_name(dev));
if (dev_name_itr != end(device_names))
{
device_names.erase(dev_name_itr);
}
throw e;
}

viewer_model.not_model->add_log(
rsutils::string::from() << ( *device_models.rbegin() )->dev.get_info( RS2_CAMERA_INFO_NAME )
<< " was selected as a default device" );
Expand Down

0 comments on commit 3aebaf9

Please sign in to comment.