BugFix: Clone source failed do not crash

Clone source that lost its origin can be replaced.
This commit is contained in:
Bruno Herbelin
2023-02-16 19:15:25 +01:00
parent e2e316a079
commit 16931917b7
4 changed files with 23 additions and 13 deletions

View File

@@ -212,8 +212,9 @@ guint64 CloneSource::playtime () const
{
if (filter_->type() != FrameBufferFilter::FILTER_PASSTHROUGH)
return guint64( filter_->updateTime() * GST_SECOND ) ;
if (origin_)
return origin_->playtime();
return 0;
}
@@ -221,7 +222,6 @@ uint CloneSource::texture() const
{
if (origin_)
return origin_->frame()->texture();
else
return Resource::getTextureBlack();
}

View File

@@ -1043,11 +1043,18 @@ void ImGuiVisitor::visit (CloneSource& s)
}
// link to origin source
if ( !s.failed() ) {
std::string label = std::string(s.origin()->initials()) + " - " + s.origin()->name();
if (ImGui::Button(label.c_str(), ImVec2(IMGUI_RIGHT_ALIGN, 0) ))
Mixer::manager().setCurrentSource(s.origin());
ImGui::SameLine(0, IMGUI_SAME_LINE);
ImGui::Text("Origin");
}
else {
ImGuiToolkit::ButtonDisabled("No source", ImVec2(IMGUI_RIGHT_ALIGN, 0) );
ImGui::SameLine(0, IMGUI_SAME_LINE);
ImGui::Text("Origin");
}
// filter selection
std::ostringstream oss;

View File

@@ -223,12 +223,12 @@ void InfoVisitor::visit (RenderSource& s)
void InfoVisitor::visit (CloneSource& s)
{
if (current_id_ == s.id() || s.origin() == nullptr)
if (current_id_ == s.id() && !s.failed())
return;
std::ostringstream oss;
if (s.frame()){
if (!s.failed() && s.frame()){
if (brief_) {
oss << (s.frame()->flags() & FrameBuffer::FrameBuffer_alpha ? "RGBA, " : "RGB, ");
oss << s.frame()->width() << " x " << s.frame()->height();
@@ -241,6 +241,8 @@ void InfoVisitor::visit (CloneSource& s)
oss << s.frame()->width() << " x " << s.frame()->height();
}
}
else
oss << "Undefined";
information_ = oss.str();
current_id_ = s.id();

View File

@@ -247,13 +247,14 @@ void Session::update(float dt)
// insert source in list of failed
// (NB: insert in set fails if source is already listed)
failed_.insert( *it );
// do not render
render_.scene.ws()->detach( (*it)->group(View::RENDERING) );
}
// render normally
else {
// session is not ready if one source is not ready
if ( !(*it)->ready() )
ready = false;
// set inputs
// update the source
(*it)->setActive(activation_threshold_);
(*it)->update(dt);