diff --git a/source/filters/filter-shader.cpp b/source/filters/filter-shader.cpp index a52d5ce..5754216 100644 --- a/source/filters/filter-shader.cpp +++ b/source/filters/filter-shader.cpp @@ -67,7 +67,7 @@ filter::shader::shader_factory::shader_factory() _source_info.create = [](obs_data_t* data, obs_source_t* self) { try { return static_cast(new filter::shader::shader_instance(data, self)); - } catch (std::exception& ex) { + } catch (const std::exception& ex) { P_LOG_ERROR(" Failed to create source, error: %s", ex.what()); } catch (...) { P_LOG_ERROR(" Failed to create source."); @@ -77,7 +77,7 @@ filter::shader::shader_factory::shader_factory() _source_info.destroy = [](void* ptr) { try { delete reinterpret_cast(ptr); - } catch (std::exception& ex) { + } catch (const std::exception& ex) { P_LOG_ERROR(" Failed to delete source, error: %s", ex.what()); } catch (...) { P_LOG_ERROR(" Failed to delete source."); @@ -88,7 +88,7 @@ filter::shader::shader_factory::shader_factory() try { if (ptr) reinterpret_cast(ptr)->properties(pr); - } catch (std::exception& ex) { + } catch (const std::exception& ex) { P_LOG_ERROR(" Failed to retrieve options, error: %s", ex.what()); } catch (...) { P_LOG_ERROR(" Failed to retrieve options."); @@ -99,7 +99,7 @@ filter::shader::shader_factory::shader_factory() try { if (ptr) return reinterpret_cast(ptr)->width(); - } catch (std::exception& ex) { + } catch (const std::exception& ex) { P_LOG_ERROR(" Failed to retrieve width, error: %s", ex.what()); } catch (...) { P_LOG_ERROR(" Failed to retrieve width."); @@ -110,7 +110,7 @@ filter::shader::shader_factory::shader_factory() try { if (ptr) return reinterpret_cast(ptr)->height(); - } catch (std::exception& ex) { + } catch (const std::exception& ex) { P_LOG_ERROR(" Failed to retrieve height, error: %s", ex.what()); } catch (...) { P_LOG_ERROR(" Failed to retrieve height."); @@ -121,7 +121,7 @@ filter::shader::shader_factory::shader_factory() try { if (ptr) reinterpret_cast(ptr)->load(data); - } catch (std::exception& ex) { + } catch (const std::exception& ex) { P_LOG_ERROR(" Failed to load, error: %s", ex.what()); } catch (...) { P_LOG_ERROR(" Failed to load."); @@ -131,7 +131,7 @@ filter::shader::shader_factory::shader_factory() try { if (ptr) reinterpret_cast(ptr)->update(data); - } catch (std::exception& ex) { + } catch (const std::exception& ex) { P_LOG_ERROR(" Failed to update, error: %s", ex.what()); } catch (...) { P_LOG_ERROR(" Failed to update."); @@ -141,7 +141,7 @@ filter::shader::shader_factory::shader_factory() try { if (ptr) reinterpret_cast(ptr)->activate(); - } catch (std::exception& ex) { + } catch (const std::exception& ex) { P_LOG_ERROR(" Failed to activate, error: %s", ex.what()); } catch (...) { P_LOG_ERROR(" Failed to activate."); @@ -151,7 +151,7 @@ filter::shader::shader_factory::shader_factory() try { if (ptr) reinterpret_cast(ptr)->deactivate(); - } catch (std::exception& ex) { + } catch (const std::exception& ex) { P_LOG_ERROR(" Failed to deactivate, error: %s", ex.what()); } catch (...) { P_LOG_ERROR(" Failed to deactivate."); @@ -161,7 +161,7 @@ filter::shader::shader_factory::shader_factory() try { if (ptr) reinterpret_cast(ptr)->video_tick(time); - } catch (std::exception& ex) { + } catch (const std::exception& ex) { P_LOG_ERROR(" Failed to tick, error: %s", ex.what()); } catch (...) { P_LOG_ERROR(" Failed to tick."); @@ -171,7 +171,7 @@ filter::shader::shader_factory::shader_factory() try { if (ptr) reinterpret_cast(ptr)->video_render(effect); - } catch (std::exception& ex) { + } catch (const std::exception& ex) { P_LOG_ERROR(" Failed to render, error: %s", ex.what()); } catch (...) { P_LOG_ERROR(" Failed to render."); @@ -181,7 +181,7 @@ filter::shader::shader_factory::shader_factory() try { if (ptr) reinterpret_cast(ptr)->enum_active_sources(enum_callback, param); - } catch (std::exception& ex) { + } catch (const std::exception& ex) { P_LOG_ERROR(" Failed to enumerate sources, error: %s", ex.what()); } catch (...) { P_LOG_ERROR(" Failed to enumerate sources."); @@ -223,6 +223,8 @@ bool modifiedcb3(obs_properties_t* props, obs_property_t* property, obs_data_t* obs_property_set_visible(obs_properties_get(props, ST_SCALE_WIDTH), !obs_data_get_bool(settings, ST_SCALE_LOCKED)); obs_property_set_visible(obs_properties_get(props, ST_SCALE_HEIGHT), !obs_data_get_bool(settings, ST_SCALE_LOCKED)); return true; +} catch (const std::exception& ex) { + P_LOG_ERROR("Unexpected exception in function '%s': %s.", __FUNCTION_NAME__, ex.what()); } catch (...) { P_LOG_ERROR("Unexpected exception in function '%s'.", __FUNCTION_NAME__); return false; diff --git a/source/gfx/gfx-effect-source.cpp b/source/gfx/gfx-effect-source.cpp index f978fdd..ecf98a3 100644 --- a/source/gfx/gfx-effect-source.cpp +++ b/source/gfx/gfx-effect-source.cpp @@ -873,7 +873,7 @@ void gfx::effect_source::texture_parameter::update(obs_data_t* data) _source_renderer = std::make_shared(_source, _parent.lock()->get_self()); } } - } catch (std::exception& ex) { + } catch (const std::exception& ex) { P_LOG_ERROR("Update failed, error: %s", ex.what()); } } @@ -893,7 +893,7 @@ void gfx::effect_source::texture_parameter::tick(float_t time) if (changed) { try { load_texture(_file_name); - } catch (std::exception& ex) { + } catch (const std::exception& ex) { P_LOG_ERROR("Loading texture \"%s\" failed, error: %s", _file_name.c_str(), ex.what()); } } @@ -941,7 +941,7 @@ bool gfx::effect_source::effect_source::modified2(obs_properties_t* props, obs_p try { const char* str = obs_data_get_string(settings, ST_FILE); load_file(str ? str : ""); - } catch (std::exception& ex) { + } catch (const std::exception& ex) { P_LOG_ERROR(" Failed to load effect \"%s\" due to error: %s", _file.c_str(), ex.what()); } @@ -1055,7 +1055,7 @@ void gfx::effect_source::effect_source::update(obs_data_t* data) if (file != _file) { try { load_file(file); - } catch (std::exception& ex) { + } catch (const std::exception& ex) { P_LOG_ERROR(" Failed to load effect \"%s\" due to error: %s", _file.c_str(), ex.what()); } } @@ -1084,7 +1084,7 @@ bool gfx::effect_source::effect_source::tick(float_t time) if (changed) { try { load_file(_file); - } catch (std::exception& ex) { + } catch (const std::exception& ex) { P_LOG_ERROR("Loading shader \"%s\" failed, error: %s", _file.c_str(), ex.what()); } return true; diff --git a/source/sources/source-shader.cpp b/source/sources/source-shader.cpp index 974c65e..ab7a9aa 100644 --- a/source/sources/source-shader.cpp +++ b/source/sources/source-shader.cpp @@ -63,7 +63,7 @@ source::shader::shader_factory::shader_factory() _source_info.create = [](obs_data_t* data, obs_source_t* self) { try { return static_cast(new source::shader::shader_instance(data, self)); - } catch (std::exception& ex) { + } catch (const std::exception& ex) { P_LOG_ERROR(" Failed to create source, error: %s", ex.what()); } catch (...) { P_LOG_ERROR(" Failed to create source."); @@ -73,7 +73,7 @@ source::shader::shader_factory::shader_factory() _source_info.destroy = [](void* ptr) { try { delete reinterpret_cast(ptr); - } catch (std::exception& ex) { + } catch (const std::exception& ex) { P_LOG_ERROR(" Failed to delete source, error: %s", ex.what()); } catch (...) { P_LOG_ERROR(" Failed to delete source."); @@ -84,7 +84,7 @@ source::shader::shader_factory::shader_factory() try { if (ptr) reinterpret_cast(ptr)->properties(pr); - } catch (std::exception& ex) { + } catch (const std::exception& ex) { P_LOG_ERROR(" Failed to retrieve options, error: %s", ex.what()); } catch (...) { P_LOG_ERROR(" Failed to retrieve options."); @@ -95,7 +95,7 @@ source::shader::shader_factory::shader_factory() try { if (ptr) return reinterpret_cast(ptr)->width(); - } catch (std::exception& ex) { + } catch (const std::exception& ex) { P_LOG_ERROR(" Failed to retrieve width, error: %s", ex.what()); } catch (...) { P_LOG_ERROR(" Failed to retrieve width."); @@ -106,7 +106,7 @@ source::shader::shader_factory::shader_factory() try { if (ptr) return reinterpret_cast(ptr)->height(); - } catch (std::exception& ex) { + } catch (const std::exception& ex) { P_LOG_ERROR(" Failed to retrieve height, error: %s", ex.what()); } catch (...) { P_LOG_ERROR(" Failed to retrieve height."); @@ -117,7 +117,7 @@ source::shader::shader_factory::shader_factory() try { if (ptr) reinterpret_cast(ptr)->load(data); - } catch (std::exception& ex) { + } catch (const std::exception& ex) { P_LOG_ERROR(" Failed to load, error: %s", ex.what()); } catch (...) { P_LOG_ERROR(" Failed to load."); @@ -127,7 +127,7 @@ source::shader::shader_factory::shader_factory() try { if (ptr) reinterpret_cast(ptr)->update(data); - } catch (std::exception& ex) { + } catch (const std::exception& ex) { P_LOG_ERROR(" Failed to update, error: %s", ex.what()); } catch (...) { P_LOG_ERROR(" Failed to update."); @@ -137,7 +137,7 @@ source::shader::shader_factory::shader_factory() try { if (ptr) reinterpret_cast(ptr)->activate(); - } catch (std::exception& ex) { + } catch (const std::exception& ex) { P_LOG_ERROR(" Failed to activate, error: %s", ex.what()); } catch (...) { P_LOG_ERROR(" Failed to activate."); @@ -147,7 +147,7 @@ source::shader::shader_factory::shader_factory() try { if (ptr) reinterpret_cast(ptr)->deactivate(); - } catch (std::exception& ex) { + } catch (const std::exception& ex) { P_LOG_ERROR(" Failed to deactivate, error: %s", ex.what()); } catch (...) { P_LOG_ERROR(" Failed to deactivate."); @@ -157,7 +157,7 @@ source::shader::shader_factory::shader_factory() try { if (ptr) reinterpret_cast(ptr)->video_tick(time); - } catch (std::exception& ex) { + } catch (const std::exception& ex) { P_LOG_ERROR(" Failed to tick, error: %s", ex.what()); } catch (...) { P_LOG_ERROR(" Failed to tick."); @@ -167,7 +167,7 @@ source::shader::shader_factory::shader_factory() try { if (ptr) reinterpret_cast(ptr)->video_render(effect); - } catch (std::exception& ex) { + } catch (const std::exception& ex) { P_LOG_ERROR(" Failed to render, error: %s", ex.what()); } catch (...) { P_LOG_ERROR(" Failed to render."); @@ -177,7 +177,7 @@ source::shader::shader_factory::shader_factory() try { if (ptr) reinterpret_cast(ptr)->enum_active_sources(enum_callback, param); - } catch (std::exception& ex) { + } catch (const std::exception& ex) { P_LOG_ERROR(" Failed to enumerate sources, error: %s", ex.what()); } catch (...) { P_LOG_ERROR(" Failed to enumerate sources."); @@ -228,8 +228,8 @@ void source::shader::shader_instance::load(obs_data_t* data) void source::shader::shader_instance::update(obs_data_t* data) { - _width = obs_data_get_int(data, ST_WIDTH); - _height = obs_data_get_int(data, ST_HEIGHT); + _width = static_cast(obs_data_get_int(data, ST_WIDTH)); + _height = static_cast(obs_data_get_int(data, ST_HEIGHT)); _fx->update(data); }