gfx-source-texture: Release child source if add_active_child fails

This commit is contained in:
Michael Fabian 'Xaymar' Dirks 2019-01-27 23:33:38 +01:00
parent 10c0081f32
commit 97bf38633b

View file

@ -57,6 +57,7 @@ gfx::source_texture::source_texture(const char* _name, obs_source_t* _parent) :
throw std::invalid_argument("source does not exist"); throw std::invalid_argument("source does not exist");
} }
if (!obs_source_add_active_child(_parent, source)) { if (!obs_source_add_active_child(_parent, source)) {
obs_source_release(source);
throw std::runtime_error("parent is contained in child"); throw std::runtime_error("parent is contained in child");
} }
child = std::make_unique<obs::source>(source, true, true); child = std::make_unique<obs::source>(source, true, true);
@ -76,8 +77,8 @@ gfx::source_texture::source_texture(std::shared_ptr<obs::source> child, std::sha
if (!obs_source_add_active_child(parent->get(), child->get())) { if (!obs_source_add_active_child(parent->get(), child->get())) {
throw std::runtime_error("parent is contained in child"); throw std::runtime_error("parent is contained in child");
} }
this->child = child; this->child = child;
this->parent = parent; this->parent = parent;
this->render_target = std::make_shared<gs::rendertarget>(GS_RGBA, GS_ZS_NONE); this->render_target = std::make_shared<gs::rendertarget>(GS_RGBA, GS_ZS_NONE);
} }