Skip to content

Commit

Permalink
options-watcher catching join exception in stop. viewer catches excep…
Browse files Browse the repository at this point in the history
…tions setting callback.
  • Loading branch information
OhadMeir committed Dec 28, 2023
1 parent cd0b14e commit 08f25fb
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 19 deletions.
22 changes: 15 additions & 7 deletions common/subdevice-model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,17 +81,25 @@ namespace rs2
auto opt = static_cast<rs2_option>(i);

opt_container[opt] = create_option_model(opt, opt_base_label, model, options, options_invalidated, error_message);
model->s->on_options_changed( [model]( const options_list & list )
try
{
for( auto opt_id : list )
model->s->on_options_changed( [model]( const options_list & list )
{
auto it = model->options_metadata.find( opt_id );
if( it != model->options_metadata.end() )
for( auto opt_id : list )
{
it->second.value = it->second.endpoint->get_option( opt_id );
auto it = model->options_metadata.find( opt_id );
if( it != model->options_metadata.end() )
{
it->second.value = it->second.endpoint->get_option( opt_id );
}
}
}
} );
} );
}
catch( const std::exception & e )
{
if( model->viewer.not_model )
model->viewer.not_model->add_log( e.what(), RS2_LOG_SEVERITY_WARN );
}
}
}

Expand Down
21 changes: 11 additions & 10 deletions src/core/options-watcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,7 @@ options_watcher::options_watcher( std::chrono::milliseconds update_interval )
options_watcher::~options_watcher()
{
_destructing = true;
try
{
_options.clear();
stop();
}
catch( ... )
{
LOG_DEBUG( "Failures taking lock or stoping thread while destructing options_watcher" );
}
stop();
}

void options_watcher::register_option( rs2_option id, std::shared_ptr< option > option )
Expand Down Expand Up @@ -88,7 +80,16 @@ void options_watcher::stop()
{
_stopping.notify_all();
if( _updater.joinable() )
_updater.join();
{
try
{
_updater.join();
}
catch( ... )
{
// Nothing to do on error
}
}
}

void options_watcher::thread_loop()
Expand Down
2 changes: 1 addition & 1 deletion src/media/playback/playback_sensor.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ namespace librealsense

rsutils::subscription register_options_changed_callback( options_watcher::callback && cb ) override
{
throw not_implemented_exception( "Registering options value changed callback is not implemented for this sensor" );
throw not_implemented_exception( "Registering options value changed callback is not implemented for playback sensor" );
}

protected:
Expand Down
2 changes: 1 addition & 1 deletion src/media/record/record_sensor.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ namespace librealsense

rsutils::subscription register_options_changed_callback( options_watcher::callback && cb ) override
{
throw not_implemented_exception( "Registering options value changed callback is not implemented for this sensor" );
throw not_implemented_exception( "Registering options value changed callback is not implemented for record sensor" );
}

private /*methods*/:
Expand Down

0 comments on commit 08f25fb

Please sign in to comment.