Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

avoid viewer exception when creating new device_model fails #13680

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we can add a LOG or something?
That we failed creating the new connected device ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure!

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
Loading