Skip to content

Commit

Permalink
Viewer - take on_option_changed subscription out of the loop
Browse files Browse the repository at this point in the history
  • Loading branch information
OhadMeir committed Feb 19, 2024
1 parent 4042471 commit 7503f22
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions common/subdevice-model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,26 +78,26 @@ namespace rs2
auto opt = static_cast<rs2_option>(i);

options_metadata[opt] = create_option_model(opt, opt_base_label, this, s, options_invalidated, error_message);
try
}
try
{
s->on_options_changed( [this]( const options_list & list )
{
s->on_options_changed( [this]( const options_list & list )
for( auto changed_option : list )
{
for( auto changed_option : list )
auto it = options_metadata.find( changed_option->id );
if( it != options_metadata.end() && ! _destructing ) // Callback runs in different context, check options_metadata still valid
{
auto it = options_metadata.find( changed_option->id );
if( it != options_metadata.end() && ! _destructing ) // Callback runs in different context, check options_metadata still valid
{
if( RS2_OPTION_TYPE_FLOAT == changed_option->type )
it->second.value = changed_option->as_float;
}
if( RS2_OPTION_TYPE_FLOAT == changed_option->type )
it->second.value = changed_option->as_float;
}
} );
}
catch( const std::exception & e )
{
if( viewer.not_model )
viewer.not_model->add_log( e.what(), RS2_LOG_SEVERITY_WARN );
}
}
} );
}
catch( const std::exception & e )
{
if( viewer.not_model )
viewer.not_model->add_log( e.what(), RS2_LOG_SEVERITY_WARN );
}
}

Expand Down

0 comments on commit 7503f22

Please sign in to comment.