Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

#818 Don't self-reference when masking is enabled #987

Merged
merged 2 commits into from
Dec 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion source/filters/filter-blur.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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::gfx::source_texture>(
::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 (...) {
Expand Down
8 changes: 4 additions & 4 deletions source/gfx/gfx-source-texture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,18 @@ 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) {
throw std::invalid_argument("Child or Parent does not exist.");
}

// 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");
}

Expand Down
3 changes: 2 additions & 1 deletion source/gfx/gfx-source-texture.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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;
Expand Down