From 5204457802c4130936eeeddf3ca71989f0a051c5 Mon Sep 17 00:00:00 2001 From: Michael Fabian 'Xaymar' Dirks Date: Fri, 2 Dec 2022 04:39:06 +0100 Subject: [PATCH 1/2] gfx/source-texture: Don't use weak_source for strong references --- source/gfx/gfx-source-texture.cpp | 8 ++++---- source/gfx/gfx-source-texture.hpp | 3 ++- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/source/gfx/gfx-source-texture.cpp b/source/gfx/gfx-source-texture.cpp index 1066f11752..56b63e2562 100644 --- a/source/gfx/gfx-source-texture.cpp +++ b/source/gfx/gfx-source-texture.cpp @@ -30,8 +30,8 @@ streamfx::gfx::source_texture::~source_texture() } } -streamfx::gfx::source_texture::source_texture(streamfx::obs::weak_source child, streamfx::obs::weak_source parent) - : _parent(parent.lock()), _child(child.lock()) +streamfx::gfx::source_texture::source_texture(streamfx::obs::source child, streamfx::obs::source parent) + : _parent(parent), _child(child) { // Verify that 'child' and 'parent' exist. if (!_child || !_parent) { @@ -39,9 +39,9 @@ streamfx::gfx::source_texture::source_texture(streamfx::obs::weak_source child, } // Verify that 'child' does not contain 'parent'. - if (::streamfx::obs::tools::source_find_source(_child, _parent)) { + if (::streamfx::obs::tools::source_find_source(child, parent)) { throw std::runtime_error("Child contains Parent"); - } else if (!obs_source_add_active_child(_parent.get(), _child.get())) { + } else if (!obs_source_add_active_child(parent, child)) { throw std::runtime_error("Child contains Parent"); } diff --git a/source/gfx/gfx-source-texture.hpp b/source/gfx/gfx-source-texture.hpp index 5eae0fc28a..dd09f623aa 100644 --- a/source/gfx/gfx-source-texture.hpp +++ b/source/gfx/gfx-source-texture.hpp @@ -19,6 +19,7 @@ #include "common.hpp" #include "obs/gs/gs-rendertarget.hpp" #include "obs/gs/gs-texture.hpp" +#include "obs/obs-source.hpp" #include "obs/obs-weak-source.hpp" #include "warning-disable.hpp" @@ -34,7 +35,7 @@ namespace streamfx::gfx { public: ~source_texture(); - source_texture(streamfx::obs::weak_source child, streamfx::obs::weak_source parent); + source_texture(streamfx::obs::source child, streamfx::obs::source parent); public /*copy*/: source_texture(source_texture const& other) = delete; From 6e29a18266652bc2dd3d35f4f7c14a0cbd3a1aa9 Mon Sep 17 00:00:00 2001 From: Michael Fabian 'Xaymar' Dirks Date: Fri, 2 Dec 2022 04:39:29 +0100 Subject: [PATCH 2/2] filter/blur: Don't increment your own reference count Fixes #818 --- source/filters/filter-blur.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/filters/filter-blur.cpp b/source/filters/filter-blur.cpp index ad3059a47b..50dcb0a129 100644 --- a/source/filters/filter-blur.cpp +++ b/source/filters/filter-blur.cpp @@ -377,7 +377,7 @@ void blur_instance::video_tick(float) if (_mask.source.name_old != _mask.source.name) { try { _mask.source.source_texture = std::make_shared( - ::streamfx::obs::weak_source(_mask.source.name), ::streamfx::obs::weak_source(_self)); + ::streamfx::obs::source{_mask.source.name}, ::streamfx::obs::source{_self, false}); _mask.source.is_scene = (obs_scene_from_source(_mask.source.source_texture->get_object()) != nullptr); _mask.source.name_old = _mask.source.name; } catch (...) {