Skip to content

Make uvc sensor weak pointer - #12484

Merged
Nir-Az merged 3 commits into
realsenseai:developmentfrom
Tamir91:fix-crashing-linux-backend
Dec 10, 2023
Merged

Make uvc sensor weak pointer#12484
Nir-Az merged 3 commits into
realsenseai:developmentfrom
Tamir91:fix-crashing-linux-backend

Conversation

@Tamir91

@Tamir91 Tamir91 commented Dec 5, 2023

Copy link
Copy Markdown
Contributor

Tracked on [RSDSO-19355]

Comment thread src/ds/d400/d400-device.cpp Outdated
auto& depth_sensor = get_depth_sensor();
auto& raw_depth_sensor = get_raw_depth_sensor();

//_raw_depth_sensor2 = dynamic_cast<>.get_raw_sensor();

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Comment deleted

Comment thread src/ds/d400/d400-device.cpp Outdated

depth_sensor.register_option(RS2_OPTION_ASIC_TEMPERATURE,
std::make_shared<asic_and_projector_temperature_options>(raw_depth_sensor,
std::make_shared<asic_and_projector_temperature_options>(std::dynamic_pointer_cast<uvc_sensor>(raw_depth_sensor.shared_from_this()),

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Coverity will yell here,
You know how to solve it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Null checking added.

Comment thread src/ds/d400/d400-device.cpp Outdated

depth_ep.register_option(RS2_OPTION_PROJECTOR_TEMPERATURE,
std::make_shared<asic_and_projector_temperature_options>(depth_ep,
std::make_shared<asic_and_projector_temperature_options>(std::dynamic_pointer_cast<uvc_sensor>(depth_ep.shared_from_this()),

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

same

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Null checking added.

Comment thread src/ds/ds-active-common.cpp Outdated
{
_depth_ep.register_option(RS2_OPTION_PROJECTOR_TEMPERATURE,
std::make_shared<asic_and_projector_temperature_options>(_raw_depth_ep,
std::make_shared<asic_and_projector_temperature_options>(std::dynamic_pointer_cast<uvc_sensor>(_raw_depth_ep.shared_from_this()),

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

same

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Null checking added.

Comment thread src/ds/ds-options.cpp Outdated
auto temperature_data = static_cast<temperature>(_ep.invoke_powered(
auto strong_ep = _ep.lock();
if (!strong_ep)
throw invalid_value_exception(rsutils::string::from() << "EP is not exists");

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Who will catch this exception?
BTW
EP does not exists

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

During our previous conversation, we agreed to leave the use of the throw.
The string has been renamed.

Comment thread src/ds/ds-options.cpp Outdated
return _ep.is_streaming();
auto strong_ep = _ep.lock();
if (!strong_ep)
throw invalid_value_exception(rsutils::string::from() << "Can not retriev temperature as no valid EP");

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Instead of throw, maybe we should return false and log_warning this issue

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

During our previous conversation, we agreed to leave the use of the throw.

Comment thread src/ds/ds-options.cpp
Comment thread src/ds/ds-options.cpp
Checking dynamic casts
Exception type changed
@Tamir91
Tamir91 requested a review from Nir-Az December 7, 2023 08:28

@Nir-Az Nir-Az left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM

@Nir-Az
Nir-Az merged commit 59ffb92 into realsenseai:development Dec 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants