diff --git a/src/callback-invocation.h b/src/callback-invocation.h index 162a905176..4e67c02f23 100644 --- a/src/callback-invocation.h +++ b/src/callback-invocation.h @@ -44,8 +44,17 @@ struct callback_invocation_holder ~callback_invocation_holder() { - if( invocation ) - owner->deallocate( invocation ); + if( invocation && owner ) + { + try + { + owner->deallocate( invocation ); + } + catch( const std::exception & e ) + { + LOG_DEBUG( "Error while callback holder deallocation: " << e.what() ); + } + } } callback_invocation_holder & operator=( callback_invocation_holder && other ) diff --git a/src/gl/align-gl.cpp b/src/gl/align-gl.cpp index 462edc3abc..d9fef743d1 100644 --- a/src/gl/align-gl.cpp +++ b/src/gl/align-gl.cpp @@ -274,8 +274,15 @@ align_gl::align_gl(rs2_stream to_stream) : align(to_stream, "Align (GLSL)") align_gl::~align_gl() { - perform_gl_action([&]() + try { - cleanup_gpu_resources(); - }, []{}); + perform_gl_action( [&]() + { + cleanup_gpu_resources(); + }, [] {} ); + } + catch(...) + { + LOG_DEBUG( "Error while cleaning up gpu resources" ); + } } diff --git a/src/gl/colorizer-gl.cpp b/src/gl/colorizer-gl.cpp index 74e334ed2d..fb70e763ea 100644 --- a/src/gl/colorizer-gl.cpp +++ b/src/gl/colorizer-gl.cpp @@ -175,10 +175,17 @@ namespace librealsense colorizer::~colorizer() { - perform_gl_action([&]() + try { - cleanup_gpu_resources(); - }, []{}); + perform_gl_action( [&]() + { + cleanup_gpu_resources(); + }, [] {} ); + } + catch(...) + { + LOG_DEBUG( "Error while performing cleaning up gpu resources" ); + } } void colorizer::populate_floating_histogram(float* f, int* hist) diff --git a/src/gl/pointcloud-gl.cpp b/src/gl/pointcloud-gl.cpp index ab313b618f..d2ceb2995b 100644 --- a/src/gl/pointcloud-gl.cpp +++ b/src/gl/pointcloud-gl.cpp @@ -388,10 +388,17 @@ void pointcloud_gl::create_gpu_resources() pointcloud_gl::~pointcloud_gl() { - perform_gl_action([&]() + try { - cleanup_gpu_resources(); - }, []{}); + perform_gl_action( [&]() + { + cleanup_gpu_resources(); + }, [] {} ); + } + catch(...) + { + LOG_DEBUG( "Error while cleaning up gpu resources" ); + } } pointcloud_gl::pointcloud_gl() diff --git a/src/gl/synthetic-stream-gl.cpp b/src/gl/synthetic-stream-gl.cpp index bdce2f84fa..8a677f63a3 100644 --- a/src/gl/synthetic-stream-gl.cpp +++ b/src/gl/synthetic-stream-gl.cpp @@ -186,9 +186,16 @@ namespace librealsense gpu_section::~gpu_section() { backup_content = false; - perform_gl_action([&](){ - cleanup_gpu_resources(); - }, []{}); + try + { + perform_gl_action( [&]() { + cleanup_gpu_resources(); + }, [] {} ); + } + catch(...) + { + LOG_DEBUG( "Error while cleaning up gpu resources" ); + } } void gpu_section::create_gpu_resources() diff --git a/src/gl/upload.cpp b/src/gl/upload.cpp index 4292d880d2..06824773fd 100644 --- a/src/gl/upload.cpp +++ b/src/gl/upload.cpp @@ -43,10 +43,17 @@ namespace librealsense upload::~upload() { - perform_gl_action([&]() + try { - cleanup_gpu_resources(); - }, [] {}); + perform_gl_action( [&]() + { + cleanup_gpu_resources(); + }, [] {} ); + } + catch(...) + { + LOG_DEBUG( "Error while cleaning up gpu resources" ); + } } void upload::cleanup_gpu_resources() diff --git a/src/gl/y4112rgb-gl.cpp b/src/gl/y4112rgb-gl.cpp index 5b5c643f5d..76636283b6 100644 --- a/src/gl/y4112rgb-gl.cpp +++ b/src/gl/y4112rgb-gl.cpp @@ -135,10 +135,17 @@ y411_2rgb::y411_2rgb() y411_2rgb::~y411_2rgb() { - perform_gl_action([&]() + try { - cleanup_gpu_resources(); - }, []{}); + perform_gl_action( [&]() + { + cleanup_gpu_resources(); + }, [] {} ); + } + catch(...) + { + LOG_DEBUG( "Error while cleaning up gpu resources" ); + } } rs2::frame y411_2rgb::process_frame(const rs2::frame_source& src, const rs2::frame& f) diff --git a/src/gl/yuy2rgb-gl.cpp b/src/gl/yuy2rgb-gl.cpp index 16d3621543..f3de0d9d5c 100644 --- a/src/gl/yuy2rgb-gl.cpp +++ b/src/gl/yuy2rgb-gl.cpp @@ -118,10 +118,17 @@ yuy2rgb::yuy2rgb() yuy2rgb::~yuy2rgb() { - perform_gl_action([&]() + try { - cleanup_gpu_resources(); - }, []{}); + perform_gl_action( [&]() + { + cleanup_gpu_resources(); + }, [] {} ); + } + catch(...) + { + LOG_DEBUG( "Error while cleaning up gpu resources" ); + } } rs2::frame yuy2rgb::process_frame(const rs2::frame_source& src, const rs2::frame& f) diff --git a/src/hw-monitor.h b/src/hw-monitor.h index 0b19de2602..39ae0d5693 100644 --- a/src/hw-monitor.h +++ b/src/hw-monitor.h @@ -225,7 +225,14 @@ namespace librealsense ~locked_transfer() { - _heap.wait_until_empty(); + try + { + _heap.wait_until_empty(); + } + catch(...) + { + LOG_DEBUG( "Error while waiting for an empty heap" ); + } } private: std::shared_ptr _command_transfer; diff --git a/src/linux/backend-hid.cpp b/src/linux/backend-hid.cpp index 1b599478b9..77951112fb 100644 --- a/src/linux/backend-hid.cpp +++ b/src/linux/backend-hid.cpp @@ -56,7 +56,14 @@ namespace librealsense hid_input::~hid_input() { - enable(false); + try + { + enable( false ); + } + catch(...) + { + LOG_DEBUG( "Error while disabling a hid device" ); + } } // enable scan input. doing so cause the input to be part of the data provided in the polling. @@ -954,7 +961,14 @@ namespace librealsense { for (auto& elem : _streaming_iio_sensors) { - elem->stop_capture(); + try + { + elem->stop_capture(); + } + catch(...) + { + LOG_DEBUG( "Error while stopping capture sensor" ); + } } for (auto& elem : _streaming_custom_sensors) diff --git a/src/linux/backend-v4l2.cpp b/src/linux/backend-v4l2.cpp index 7977fd6495..5895cada13 100644 --- a/src/linux/backend-v4l2.cpp +++ b/src/linux/backend-v4l2.cpp @@ -178,7 +178,14 @@ namespace librealsense named_mutex::~named_mutex() { - unlock(); + try + { + unlock(); + } + catch(...) + { + LOG_DEBUG( "Error while unlocking mutex" ); + } } void named_mutex::lock() diff --git a/src/linux/udev-device-watcher.cpp b/src/linux/udev-device-watcher.cpp index 5d4c246a66..103dc523c1 100644 --- a/src/linux/udev-device-watcher.cpp +++ b/src/linux/udev-device-watcher.cpp @@ -179,8 +179,14 @@ udev_device_watcher::udev_device_watcher( const platform::backend * backend ) udev_device_watcher::~udev_device_watcher() { - stop(); - + try + { + stop(); + } + catch(...) + { + LOG_DEBUG( "Error while stopping udev device watcher" ); + } /* Release the udev monitor */ if( _udev_monitor ) udev_monitor_unref( _udev_monitor ); diff --git a/src/sync.cpp b/src/sync.cpp index dbc7eeb532..68f5fa7d64 100644 --- a/src/sync.cpp +++ b/src/sync.cpp @@ -79,7 +79,14 @@ namespace librealsense LOG_WARNING(callbacks_inflight << " callbacks are still running on some other threads. Waiting until all callbacks return..."); } // wait until user is done with all the stuff he chose to borrow - _callback_inflight.wait_until_empty(); + try + { + _callback_inflight.wait_until_empty(); + } + catch( const std::exception & e ) + { + LOG_DEBUG( "Error while waiting for user callback to finish: " << e.what() ); + } } identity_matcher::identity_matcher(stream_id stream, rs2_stream stream_type)