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

Fix formats-converter bug #12029

Merged
merged 2 commits into from Jul 25, 2023
Merged

Conversation

OhadMeir
Copy link
Contributor

The bug happened when more than one raw profile have mapped to the same converted profile.
Saved shared_ptr object in map instead of actual profile values. Different shared_ptr objects did not map as the same key even when pointing to profiles of same values.


if( profile )
{
res += std::string( "(" ) + rs2_stream_to_string( profile->get_stream_type() ) + std::string( ")" );
Copy link
Collaborator

Choose a reason for hiding this comment

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

Wouldn't it be cleaner to just use ostringstream instead of all the std::string conversions? Or even an operator<<?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated to operator<<

@OhadMeir OhadMeir marked this pull request as ready for review July 25, 2023 07:14
@@ -57,38 +57,34 @@ void formats_converter::drop_non_basic_formats()
}
}

std::string to_string( std::shared_ptr< stream_profile_interface > profile )
std::ostream & operator<<( std::ostream & os, const std::shared_ptr< stream_profile_interface > & profile )
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you please add the required include on top?
So we will not be depending on other headers?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added

@@ -57,6 +59,24 @@ void formats_converter::drop_non_basic_formats()
}
}

std::ostream & operator<<( std::ostream & os, const std::shared_ptr< stream_profile_interface > & profile )
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is a very useful function and we keep re-implementing it in one way or another all over the place.
I suggest it be placed in a central place and not just here.
src/core/streaming.h is where stream_profile_interface is defined, I suggest the signature there and the body in a .cpp somwhere.

Copy link
Collaborator

Choose a reason for hiding this comment

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

p.s. we have to choose whether the syntax would be:
... << stm_ptr;
or
... << *stm_ptr;
I.e., do we pass the (SMART) POINTER to the stream interface, or a reference to it? I think we're not always going to have a smart ptr. I vote for a reference, if possible.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

A reference will be problematic since it is an abstract class. Maybe we can pass a raw pointer but I don't think that we use it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

A general operator for stream_profile_interface is implemented here. It does not print all the details I wanted so I added specifically here. Do you think we need it also elsewhere? No other implementations/uses that I was able to find.

Copy link
Collaborator

Choose a reason for hiding this comment

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

A reference will be problematic since it is an abstract class. Maybe we can pass a raw pointer but I don't think that we use it.

A ref is just syntax, it doesn't mean anything. You can take its address, compare it to null, etc., same as any pointer.

Copy link
Collaborator

Choose a reason for hiding this comment

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

A general operator for stream_profile_interface is implemented here.

That's for stream_profiles. I vote for yours, and change that one to use it.

@Nir-Az
Copy link
Collaborator

Nir-Az commented Jul 25, 2023

We are waiting for this fix in several other branches, we cannot merge D457 changes for ADL-P safely
Let's first merge the fix, see we are back to safe and then think about the enhancement

@Nir-Az
Copy link
Collaborator

Nir-Az commented Jul 25, 2023

We are waiting for this fix in several other branches, we cannot merge D457 changes for ADL-P safely Let's first merge the fix, see we are back to safe and then think about the enhancement

@maloel note that we are blind in GHA DDS tests, we will not rerun until it will pass..

@maloel
Copy link
Collaborator

maloel commented Jul 25, 2023

We are waiting for this fix in several other branches, we cannot merge D457 changes for ADL-P safely Let's first merge the fix, see we are back to safe and then think about the enhancement

¯\_(ツ)_/¯

I'm just commenting on something minor, up to you...

@Nir-Az Nir-Az merged commit ab5dfbe into IntelRealSense:development Jul 25, 2023
15 of 17 checks passed
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.

None yet

3 participants