Repository navigation
Handle exceptions during device creation - #11625
Merged
Merged
Conversation
Nir-Az
reviewed
Mar 28, 2023
| } | ||
|
|
||
| device::device(std::shared_ptr<context> ctx, | ||
| device::device( std::shared_ptr<context> ctx, |
Collaborator
There was a problem hiding this comment.
Can we avoid unrelated format changes for this PR?
Lets focus on the main changes
Contributor
Author
There was a problem hiding this comment.
Done.
Although I do prefer to fix bad formatting where I make changes anyway. Could be more easily compared in the VSCode view :-)
Nir-Az
approved these changes
Mar 28, 2023
maloel
reviewed
Mar 30, 2023
| if (_device_changed_notifications) | ||
| { | ||
| auto cb = new devices_changed_callback_internal([this](rs2_device_list* removed, rs2_device_list* added) | ||
| std::weak_ptr< bool > weak = std::make_shared< bool >( _is_alive ); |
Contributor
There was a problem hiding this comment.
This shouldn't work!
Make the shared - good.
Make the weak - good.
Destroy the shared - because nobody's holding it!
Now in the callback, weak.lock() has no strong pointer alive, it will return null...
@OhadMeir please review
Collaborator
There was a problem hiding this comment.
You are right.
I think we missed that
bool _is_alive;
should be
std::shared_ptr<bool> _is_alive;
and add the _alive(make_shared<bool>(true)).. in the Ctor or something like that.
Merged
Contributor
Author
|
Superseded by PR#11636 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
[DSO-18785]
Add flag protected by a weak_ptr to verify object is still "alive" when used by callback.